зеркало из https://github.com/mozilla/gecko-dev.git
b=500883; put canvas3d into core (disabled by default, configure flag to enable); r=me,npotb
This commit is contained in:
Родитель
a33acd773d
Коммит
e904e6da92
|
@ -237,6 +237,7 @@ MOZ_XTF = @MOZ_XTF@
|
|||
MOZ_NO_INSPECTOR_APIS = @MOZ_NO_INSPECTOR_APIS@
|
||||
MOZ_SVG = @MOZ_SVG@
|
||||
MOZ_ENABLE_CANVAS = @MOZ_ENABLE_CANVAS@
|
||||
MOZ_ENABLE_CANVAS3D = @MOZ_ENABLE_CANVAS3D@
|
||||
MOZ_CAIRO_CFLAGS = @MOZ_CAIRO_CFLAGS@
|
||||
MOZ_SMIL = @MOZ_SMIL@
|
||||
MOZ_XSLT_STANDALONE = @MOZ_XSLT_STANDALONE@
|
||||
|
|
10
configure.in
10
configure.in
|
@ -4491,6 +4491,7 @@ MOZ_ACTIVEX_SCRIPTING_SUPPORT=
|
|||
MOZ_BRANDING_DIRECTORY=
|
||||
MOZ_DBGRINFO_MODULES=
|
||||
MOZ_ENABLE_CANVAS=1
|
||||
MOZ_ENABLE_CANVAS3D=
|
||||
MOZ_FEEDS=1
|
||||
MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
|
||||
MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
|
||||
|
@ -5915,6 +5916,15 @@ if test -n "$MOZ_ENABLE_CANVAS"; then
|
|||
fi
|
||||
AC_SUBST(MOZ_ENABLE_CANVAS)
|
||||
|
||||
MOZ_ARG_ENABLE_BOOL(canvas3d,
|
||||
[ --enable-canvas3d Enable canvas 3D context],
|
||||
MOZ_ENABLE_CANVAS3D=1,
|
||||
MOZ_ENABLE_CANVAS3D= )
|
||||
if test -n "$MOZ_ENABLE_CANVAS3D"; then
|
||||
AC_DEFINE(MOZ_ENABLE_CANVAS3D)
|
||||
fi
|
||||
AC_SUBST(MOZ_ENABLE_CANVAS3D)
|
||||
|
||||
dnl ========================================================
|
||||
dnl SVG
|
||||
dnl ========================================================
|
||||
|
|
|
@ -49,4 +49,8 @@ EXPORTS = \
|
|||
nsICanvasElement.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsICanvasGLPrivate.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 canvas 3D.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* These are private interface that's used to identify
|
||||
* specific concrete classes so we know what we can cast.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(eba2aa03-ae19-46e2-bad7-6b966037e22c)]
|
||||
interface nsICanvasGLBuffer : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
[scriptable, uuid(27310aab-1988-43e8-882e-6293c8c9df60)]
|
||||
interface nsICanvasGLTexture : nsISupports
|
||||
{
|
||||
};
|
|
@ -74,6 +74,36 @@ CPPSRCS = \
|
|||
nsCanvasRenderingContext2D.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Canvas 3D Pieces
|
||||
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
|
||||
CPPSRCS += \
|
||||
nsCanvasRenderingContextGL.cpp \
|
||||
nsCanvasRenderingContextGLWeb20.cpp \
|
||||
glwrap.cpp \
|
||||
nsGLPbuffer.cpp \
|
||||
nsGLPbufferOSMesa.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_X11
|
||||
EXTRA_DSO_LIBS += X11
|
||||
CPPSRCS += nsGLPbufferGLX.cpp
|
||||
DEFINES += -DUSE_GLX
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += nsGLPbufferWGL.cpp
|
||||
DEFINES += -DUSE_WGL
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
|
||||
CPPSRCS += nsGLPbufferCGL.cpp
|
||||
DEFINES += -DUSE_CGL
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
|
|
|
@ -0,0 +1,390 @@
|
|||
#ifndef _NATIVEJSCONTEXT_H_
|
||||
#define _NATIVEJSCONTEXT_H_
|
||||
|
||||
class JSObjectHelper;
|
||||
|
||||
class NativeJSContext {
|
||||
public:
|
||||
NativeJSContext() {
|
||||
error = gXPConnect->GetCurrentNativeCallContext(&ncc);
|
||||
if (NS_FAILED(error))
|
||||
return;
|
||||
|
||||
if (!ncc) {
|
||||
error = NS_ERROR_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = nsnull;
|
||||
|
||||
error = ncc->GetJSContext(&ctx);
|
||||
if (NS_FAILED(error))
|
||||
return;
|
||||
|
||||
JS_BeginRequest(ctx);
|
||||
|
||||
ncc->GetArgc(&argc);
|
||||
ncc->GetArgvPtr(&argv);
|
||||
}
|
||||
|
||||
~NativeJSContext() {
|
||||
JS_EndRequest(ctx);
|
||||
}
|
||||
|
||||
PRBool CheckArray (JSObject *obj, jsuint *sz) {
|
||||
if (obj &&
|
||||
::JS_IsArrayObject(ctx, obj) &&
|
||||
::JS_GetArrayLength(ctx, obj, sz))
|
||||
return PR_TRUE;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool CheckArray (jsval val, jsuint *sz) {
|
||||
if (!JSVAL_IS_NULL(val) &&
|
||||
JSVAL_IS_OBJECT(val) &&
|
||||
::JS_IsArrayObject(ctx, JSVAL_TO_OBJECT(val)) &&
|
||||
::JS_GetArrayLength(ctx, JSVAL_TO_OBJECT(val), sz))
|
||||
return PR_TRUE;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool AddGCRoot (void *aPtr, const char *aName) {
|
||||
return JS_AddNamedRootRT(gScriptRuntime, aPtr, aName);
|
||||
}
|
||||
|
||||
void ReleaseGCRoot (void *aPtr) {
|
||||
JS_RemoveRootRT(gScriptRuntime, aPtr);
|
||||
}
|
||||
|
||||
void SetRetVal (PRInt32 val) {
|
||||
if (INT_FITS_IN_JSVAL(val))
|
||||
SetRetValAsJSVal(INT_TO_JSVAL(val));
|
||||
else
|
||||
SetRetVal((double) val);
|
||||
}
|
||||
|
||||
void SetRetVal (PRUint32 val) {
|
||||
if (INT_FITS_IN_JSVAL(val))
|
||||
SetRetValAsJSVal(INT_TO_JSVAL((int) val));
|
||||
else
|
||||
SetRetVal((double) val);
|
||||
}
|
||||
|
||||
void SetRetVal (double val) {
|
||||
jsval *vp;
|
||||
ncc->GetRetValPtr(&vp);
|
||||
JS_NewDoubleValue(ctx, val, vp);
|
||||
}
|
||||
|
||||
void SetBoolRetVal (PRBool val) {
|
||||
if (val)
|
||||
SetRetValAsJSVal(JSVAL_TRUE);
|
||||
else
|
||||
SetRetValAsJSVal(JSVAL_FALSE);
|
||||
}
|
||||
|
||||
void SetRetVal (PRInt32 *vp, PRUint32 len) {
|
||||
nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
|
||||
|
||||
if (!JS_EnterLocalRootScope(ctx))
|
||||
return; // XXX ???
|
||||
|
||||
for (PRUint32 i = 0; i < len; i++) {
|
||||
if (INT_FITS_IN_JSVAL(vp[i])) {
|
||||
jsvector[i] = INT_TO_JSVAL(vp[i]);
|
||||
} else {
|
||||
JS_NewDoubleValue(ctx, vp[i], &jsvector[i]);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
|
||||
SetRetVal(jsarr);
|
||||
|
||||
JS_LeaveLocalRootScope(ctx);
|
||||
}
|
||||
|
||||
void SetRetVal (PRUint32 *vp, PRUint32 len) {
|
||||
nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
|
||||
|
||||
if (!JS_EnterLocalRootScope(ctx))
|
||||
return; // XXX ???
|
||||
|
||||
for (PRUint32 i = 0; i < len; i++) {
|
||||
JS_NewNumberValue(ctx, vp[i], &jsvector[i]);
|
||||
}
|
||||
|
||||
JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
|
||||
SetRetVal(jsarr);
|
||||
|
||||
JS_LeaveLocalRootScope(ctx);
|
||||
}
|
||||
|
||||
void SetRetVal (double *dp, PRUint32 len) {
|
||||
nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
|
||||
|
||||
if (!JS_EnterLocalRootScope(ctx))
|
||||
return; // XXX ???
|
||||
|
||||
for (PRUint32 i = 0; i < len; i++)
|
||||
JS_NewDoubleValue(ctx, (jsdouble) dp[i], &jsvector[i]);
|
||||
|
||||
JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
|
||||
SetRetVal(jsarr);
|
||||
|
||||
JS_LeaveLocalRootScope(ctx);
|
||||
}
|
||||
|
||||
void SetRetVal (float *fp, PRUint32 len) {
|
||||
nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
|
||||
|
||||
if (!JS_EnterLocalRootScope(ctx))
|
||||
return; // XXX ???
|
||||
|
||||
for (PRUint32 i = 0; i < len; i++)
|
||||
JS_NewDoubleValue(ctx, (jsdouble) fp[i], &jsvector[i]);
|
||||
JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
|
||||
SetRetVal(jsarr);
|
||||
|
||||
JS_LeaveLocalRootScope(ctx);
|
||||
}
|
||||
|
||||
void SetRetValAsJSVal (jsval val) {
|
||||
jsval *vp;
|
||||
ncc->GetRetValPtr(&vp);
|
||||
*vp = val;
|
||||
ncc->SetReturnValueWasSet(PR_TRUE);
|
||||
}
|
||||
|
||||
void SetRetVal (JSObject *obj) {
|
||||
SetRetValAsJSVal(OBJECT_TO_JSVAL(obj));
|
||||
}
|
||||
|
||||
void SetRetVal (JSObjectHelper& objh);
|
||||
|
||||
nsAXPCNativeCallContext *ncc;
|
||||
nsresult error;
|
||||
JSContext *ctx;
|
||||
PRUint32 argc;
|
||||
jsval *argv;
|
||||
|
||||
public:
|
||||
// static JS helpers
|
||||
|
||||
static inline PRBool JSValToFloatArray (JSContext *ctx, jsval val,
|
||||
jsuint cnt, float *array)
|
||||
{
|
||||
JSObject *arrayObj;
|
||||
jsuint arrayLen;
|
||||
jsval jv;
|
||||
jsdouble dv;
|
||||
|
||||
if (!::JS_ValueToObject(ctx, val, &arrayObj) ||
|
||||
arrayObj == NULL ||
|
||||
!::JS_IsArrayObject(ctx, arrayObj) ||
|
||||
!::JS_GetArrayLength(ctx, arrayObj, &arrayLen) ||
|
||||
(arrayLen < cnt))
|
||||
return PR_FALSE;
|
||||
|
||||
for (jsuint i = 0; i < cnt; i++) {
|
||||
::JS_GetElement(ctx, arrayObj, i, &jv);
|
||||
if (!::JS_ValueToNumber(ctx, jv, &dv))
|
||||
return PR_FALSE;
|
||||
array[i] = (float) dv;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static inline PRBool JSValToDoubleArray (JSContext *ctx, jsval val,
|
||||
jsuint cnt, double *array)
|
||||
{
|
||||
JSObject *arrayObj;
|
||||
jsuint arrayLen;
|
||||
jsval jv;
|
||||
jsdouble dv;
|
||||
|
||||
if (!::JS_ValueToObject(ctx, val, &arrayObj) ||
|
||||
arrayObj == NULL ||
|
||||
!::JS_IsArrayObject(ctx, arrayObj) ||
|
||||
!::JS_GetArrayLength(ctx, arrayObj, &arrayLen) ||
|
||||
(arrayLen < cnt))
|
||||
return PR_FALSE;
|
||||
|
||||
for (jsuint i = 0; i < cnt; i++) {
|
||||
::JS_GetElement(ctx, arrayObj, i, &jv);
|
||||
if (!::JS_ValueToNumber(ctx, jv, &dv))
|
||||
return PR_FALSE;
|
||||
array[i] = dv;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static inline PRBool JSValToJSArrayAndLength (JSContext *ctx, jsval val,
|
||||
JSObject **outObj, jsuint *outLen)
|
||||
{
|
||||
JSObject *obj = nsnull;
|
||||
jsuint len;
|
||||
if (!::JS_ValueToObject(ctx, val, &obj) ||
|
||||
obj == NULL ||
|
||||
!::JS_IsArrayObject(ctx, obj) ||
|
||||
!::JS_GetArrayLength(ctx, obj, &len))
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
*outObj = obj;
|
||||
*outLen = len;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static nsresult JSValToSpecificInterface(JSContext *ctx, jsval val, T **out)
|
||||
{
|
||||
if (JSVAL_IS_NULL(val)) {
|
||||
*out = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_OBJECT(val))
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
||||
nsCOMPtr<nsISupports> isup;
|
||||
nsresult rv = gXPConnect->WrapJS(ctx, JSVAL_TO_OBJECT(val),
|
||||
NS_GET_IID(nsISupports),
|
||||
getter_AddRefs(isup));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
||||
nsCOMPtr<T> obj = do_QueryInterface(isup);
|
||||
if (!obj)
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
||||
NS_ADDREF(*out = obj.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static inline JSObject *ArrayToJSArray (JSContext *ctx,
|
||||
const PRInt32 *vals,
|
||||
const PRUint32 len)
|
||||
{
|
||||
// XXX handle ints that are too big to fit
|
||||
nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
|
||||
for (PRUint32 i = 0; i < len; i++)
|
||||
jsvector[i] = INT_TO_JSVAL(vals[i]);
|
||||
return JS_NewArrayObject(ctx, len, jsvector);
|
||||
}
|
||||
|
||||
static inline JSObject *ArrayToJSArray (JSContext *ctx,
|
||||
const PRUint32 *vals,
|
||||
const PRUint32 len)
|
||||
{
|
||||
// XXX handle ints that are too big to fit
|
||||
nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
|
||||
for (PRUint32 i = 0; i < len; i++)
|
||||
jsvector[i] = INT_TO_JSVAL(vals[i]);
|
||||
return JS_NewArrayObject(ctx, len, jsvector);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class JSObjectHelper {
|
||||
friend class NativeJSContext;
|
||||
public:
|
||||
JSObjectHelper(NativeJSContext *jsctx)
|
||||
: mCtx (jsctx)
|
||||
{
|
||||
mObject = JS_NewObject(mCtx->ctx, NULL, NULL, NULL);
|
||||
if (!mObject)
|
||||
return;
|
||||
|
||||
if (!mCtx->AddGCRoot(&mObject, "JSObjectHelperCanvas3D"))
|
||||
mObject = nsnull;
|
||||
}
|
||||
|
||||
~JSObjectHelper() {
|
||||
if (mObject && mCtx)
|
||||
mCtx->ReleaseGCRoot(&mObject);
|
||||
}
|
||||
|
||||
PRBool DefineProperty(const char *name, PRInt32 val) {
|
||||
// XXX handle too big ints
|
||||
if (!JS_DefineProperty(mCtx->ctx, mObject, name, INT_TO_JSVAL(val), NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool DefineProperty(const char *name, PRUint32 val) {
|
||||
// XXX handle too big ints
|
||||
if (!JS_DefineProperty(mCtx->ctx, mObject, name, INT_TO_JSVAL((int)val), NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool DefineProperty(const char *name, double val) {
|
||||
jsval dv;
|
||||
|
||||
if (!JS_NewDoubleValue(mCtx->ctx, val, &dv))
|
||||
return PR_FALSE;
|
||||
|
||||
if (!JS_DefineProperty(mCtx->ctx, mObject, name, dv, NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool DefineProperty(const char *name, JSObject *val) {
|
||||
if (!JS_DefineProperty(mCtx->ctx, mObject, name, OBJECT_TO_JSVAL(val), NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// Blah. We can't name this DefineProperty also because PRBool is the same as PRInt32
|
||||
PRBool DefineBoolProperty(const char *name, PRBool val) {
|
||||
if (!JS_DefineProperty(mCtx->ctx, mObject, name, val ? JS_TRUE : JS_FALSE, NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// We can't use ns*Substring, because we don't have internal linkage
|
||||
#if 0
|
||||
PRBool DefineProperty(const char *name, const nsCSubstring& val) {
|
||||
JSString *jsstr = JS_NewStringCopyN(mCtx->ctx, val.BeginReading(), val.Length());
|
||||
if (!jsstr ||
|
||||
!JS_DefineProperty(mCtx->ctx, mObject, name, STRING_TO_JSVAL(jsstr), NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool DefineProperty(const char *name, const nsSubstring& val) {
|
||||
JSString *jsstr = JS_NewUCStringCopyN(mCtx->ctx, val.BeginReading(), val.Length());
|
||||
if (!jsstr ||
|
||||
!JS_DefineProperty(mCtx->ctx, mObject, name, STRING_TO_JSVAL(jsstr), NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool DefineProperty(const char *name, const char *val, PRUint32 len) {
|
||||
JSString *jsstr = JS_NewStringCopyN(mCtx->ctx, val, len);
|
||||
if (!jsstr ||
|
||||
!JS_DefineProperty(mCtx->ctx, mObject, name, STRING_TO_JSVAL(jsstr), NULL, NULL, JSPROP_ENUMERATE))
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
JSObject *Object() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
protected:
|
||||
NativeJSContext *mCtx;
|
||||
JSObject *mObject;
|
||||
};
|
||||
|
||||
inline void
|
||||
NativeJSContext::SetRetVal(JSObjectHelper& objh) {
|
||||
SetRetValAsJSVal(OBJECT_TO_JSVAL(objh.mObject));
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,298 @@
|
|||
#ifdef C3D_STANDALONE_BUILD
|
||||
#include "c3d-standalone.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "prlink.h"
|
||||
|
||||
#include "glwrap.h"
|
||||
|
||||
#define MAX_SYMBOL_LENGTH 128
|
||||
#define MAX_SYMBOL_NAMES 5
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
|
||||
bool
|
||||
LibrarySymbolLoader::OpenLibrary(const char *library)
|
||||
{
|
||||
PRLibSpec lspec;
|
||||
lspec.type = PR_LibSpec_Pathname;
|
||||
lspec.value.pathname = library;
|
||||
|
||||
mLibrary = PR_LoadLibraryWithFlags(lspec, PR_LD_LAZY | PR_LD_LOCAL);
|
||||
if (!mLibrary)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PRFuncPtr
|
||||
LibrarySymbolLoader::LookupSymbol(const char *sym, bool tryplatform)
|
||||
{
|
||||
PRFuncPtr res = 0;
|
||||
|
||||
// try finding it in the library directly, if we have one
|
||||
if (mLibrary) {
|
||||
res = PR_FindFunctionSymbol(mLibrary, sym);
|
||||
}
|
||||
|
||||
// try finding it in the process
|
||||
if (!res) {
|
||||
PRLibrary *leakedLibRef;
|
||||
res = PR_FindFunctionSymbolAndLibrary(sym, &leakedLibRef);
|
||||
}
|
||||
|
||||
// no? then try looking it up via the lookup symbol
|
||||
if (!res && tryplatform && mLookupFunc) {
|
||||
res = mLookupFunc (sym);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
LibrarySymbolLoader::LoadSymbols(SymLoadStruct *firstStruct, bool tryplatform, const char *prefix)
|
||||
{
|
||||
char sbuf[MAX_SYMBOL_LENGTH * 2];
|
||||
|
||||
SymLoadStruct *ss = firstStruct;
|
||||
while (ss->symPointer) {
|
||||
*ss->symPointer = 0;
|
||||
|
||||
for (int i = 0; i < MAX_SYMBOL_NAMES; i++) {
|
||||
if (ss->symNames[i] == NULL)
|
||||
break;
|
||||
|
||||
const char *s = ss->symNames[i];
|
||||
if (prefix && *prefix != 0) {
|
||||
strcpy(sbuf, prefix);
|
||||
strcat(sbuf, ss->symNames[i]);
|
||||
s = sbuf;
|
||||
}
|
||||
|
||||
PRFuncPtr p = LookupSymbol(s, tryplatform);
|
||||
if (p) {
|
||||
*ss->symPointer = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ss->symPointer == 0) {
|
||||
fprintf (stderr, "Can't find symbol '%s'\n", ss->symNames[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
ss++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
OSMesaWrap::Init()
|
||||
{
|
||||
if (fCreateContextExt)
|
||||
return true;
|
||||
|
||||
SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &fCreateContextExt, { "OSMesaCreateContextExt", NULL } },
|
||||
{ (PRFuncPtr*) &fMakeCurrent, { "OSMesaMakeCurrent", NULL } },
|
||||
{ (PRFuncPtr*) &fPixelStore, { "OSMesaPixelStore", NULL } },
|
||||
{ (PRFuncPtr*) &fDestroyContext, { "OSMesaDestroyContext", NULL } },
|
||||
{ (PRFuncPtr*) &fGetCurrentContext, { "OSMesaGetCurrentContext", NULL } },
|
||||
{ (PRFuncPtr*) &fMakeCurrent, { "OSMesaMakeCurrent", NULL } },
|
||||
{ (PRFuncPtr*) &fGetProcAddress, { "OSMesaGetProcAddress", NULL } },
|
||||
{ NULL, { NULL } }
|
||||
};
|
||||
|
||||
return LoadSymbols(&symbols[0]);
|
||||
}
|
||||
|
||||
bool
|
||||
GLES20Wrap::Init(NativeGLMode mode)
|
||||
{
|
||||
if (mode & TRY_NATIVE_GL) {
|
||||
if (InitNative())
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mode & TRY_SOFTWARE_GL) {
|
||||
if (InitSoftware())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
GLES20Wrap::InitNative()
|
||||
{
|
||||
return InitWithPrefix("gl", true);
|
||||
}
|
||||
|
||||
bool
|
||||
GLES20Wrap::InitSoftware()
|
||||
{
|
||||
return InitWithPrefix("mgl", true);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX - we should really know the ARB/EXT variants of these
|
||||
* instead of only handling the symbol if it's exposed directly.
|
||||
*/
|
||||
|
||||
bool
|
||||
GLES20Wrap::InitWithPrefix(const char *prefix, bool trygl)
|
||||
{
|
||||
if (ok)
|
||||
return true;
|
||||
|
||||
SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &fActiveTexture, { "ActiveTexture", "ActiveTextureARB", NULL } },
|
||||
{ (PRFuncPtr*) &fAttachShader, { "AttachShader", "AttachShaderARB", NULL } },
|
||||
{ (PRFuncPtr*) &fBindAttribLocation, { "BindAttribLocation", "BindAttribLocationARB", NULL } },
|
||||
{ (PRFuncPtr*) &fBindBuffer, { "BindBuffer", "BindBufferARB", NULL } },
|
||||
{ (PRFuncPtr*) &fBindTexture, { "BindTexture", "BindTextureARB", NULL } },
|
||||
{ (PRFuncPtr*) &fBlendColor, { "BlendColor", NULL } },
|
||||
{ (PRFuncPtr*) &fBlendEquation, { "BlendEquation", NULL } },
|
||||
{ (PRFuncPtr*) &fBlendEquationSeparate, { "BlendEquationSeparate", "BlendEquationSeparateEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fBlendFunc, { "BlendFunc", NULL } },
|
||||
{ (PRFuncPtr*) &fBlendFuncSeparate, { "BlendFuncSeparate", "BlendFuncSeparateEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fBufferData, { "BufferData", NULL } },
|
||||
{ (PRFuncPtr*) &fBufferSubData, { "BufferSubData", NULL } },
|
||||
{ (PRFuncPtr*) &fClear, { "Clear", NULL } },
|
||||
{ (PRFuncPtr*) &fClearColor, { "ClearColor", NULL } },
|
||||
{ (PRFuncPtr*) &fClearDepth, { "ClearDepth", NULL } },
|
||||
{ (PRFuncPtr*) &fClearStencil, { "ClearStencil", NULL } },
|
||||
{ (PRFuncPtr*) &fColorMask, { "ColorMask", NULL } },
|
||||
{ (PRFuncPtr*) &fCreateProgram, { "CreateProgram", "CreateProgramARB", NULL } },
|
||||
{ (PRFuncPtr*) &fCreateShader, { "CreateShader", "CreateShaderARB", NULL } },
|
||||
{ (PRFuncPtr*) &fCullFace, { "CullFace", NULL } },
|
||||
{ (PRFuncPtr*) &fDeleteBuffers, { "DeleteBuffers", "DeleteBuffersARB", NULL } },
|
||||
{ (PRFuncPtr*) &fDeleteTextures, { "DeleteTextures", "DeleteTexturesARB", NULL } },
|
||||
{ (PRFuncPtr*) &fDeleteProgram, { "DeleteProgram", "DeleteProgramARB", NULL } },
|
||||
{ (PRFuncPtr*) &fDeleteShader, { "DeleteShader", "DeleteShaderARB", NULL } },
|
||||
{ (PRFuncPtr*) &fDetachShader, { "DetachShader", "DetachShaderARB", NULL } },
|
||||
{ (PRFuncPtr*) &fDepthFunc, { "DepthFunc", NULL } },
|
||||
{ (PRFuncPtr*) &fDepthMask, { "DepthMask", NULL } },
|
||||
{ (PRFuncPtr*) &fDepthRange, { "DepthRange", NULL } },
|
||||
{ (PRFuncPtr*) &fDisable, { "Disable", NULL } },
|
||||
{ (PRFuncPtr*) &fDisableVertexAttribArray, { "DisableVertexAttribArray", "DisableVertexAttribArrayARB", NULL } },
|
||||
{ (PRFuncPtr*) &fDrawArrays, { "DrawArrays", NULL } },
|
||||
{ (PRFuncPtr*) &fDrawElements, { "DrawElements", NULL } },
|
||||
{ (PRFuncPtr*) &fEnable, { "Enable", NULL } },
|
||||
{ (PRFuncPtr*) &fEnableVertexAttribArray, { "EnableVertexAttribArray", "EnableVertexAttribArrayARB", NULL } },
|
||||
{ (PRFuncPtr*) &fFinish, { "Finish", NULL } },
|
||||
{ (PRFuncPtr*) &fFlush, { "Flush", NULL } },
|
||||
{ (PRFuncPtr*) &fFrontFace, { "FrontFace", NULL } },
|
||||
{ (PRFuncPtr*) &fGetActiveAttrib, { "GetActiveAttrib", "GetActiveAttribARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetActiveUniform, { "GetActiveUniform", "GetActiveUniformARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetAttachedShaders, { "GetAttachedShaders", "GetAttachedShadersARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetAttribLocation, { "GetAttribLocation", "GetAttribLocationARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetIntegerv, { "GetIntegerv", NULL } },
|
||||
{ (PRFuncPtr*) &fGetDoublev, { "GetDoublev", NULL } },
|
||||
{ (PRFuncPtr*) &fGetFloatv, { "GetFloatv", NULL } },
|
||||
{ (PRFuncPtr*) &fGetBooleanv, { "GetBooleanv", NULL } },
|
||||
{ (PRFuncPtr*) &fGetBufferParameteriv, { "GetBufferParameteriv", "GetBufferParameterivARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGenBuffers, { "GenBuffers", "GenBuffersARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGenTextures, { "GenTextures", NULL } },
|
||||
{ (PRFuncPtr*) &fGetError, { "GetError", NULL } },
|
||||
{ (PRFuncPtr*) &fGetProgramiv, { "GetProgramiv", "GetProgramivARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetProgramInfoLog, { "GetProgramInfoLog", "GetProgramInfoLogARB", NULL } },
|
||||
{ (PRFuncPtr*) &fTexParameteri, { "TexParameteri", NULL } },
|
||||
{ (PRFuncPtr*) &fTexParameterf, { "TexParameterf", NULL } },
|
||||
{ (PRFuncPtr*) &fGetTexParameteriv, { "GetTexParameteriv", NULL } },
|
||||
{ (PRFuncPtr*) &fGetUniformfv, { "GetUniformfv", "GetUniformfvARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetUniformiv, { "GetUniformiv", "GetUniformivARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetUniformLocation, { "GetUniformLocation", "GetUniformLocationARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetVertexAttribdv, { "GetVertexAttribdv", "GetVertexAttribdvARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetVertexAttribfv, { "GetVertexAttribfv", "GetVertexAttribfvARB", NULL } },
|
||||
{ (PRFuncPtr*) &fGetVertexAttribiv, { "GetVertexAttribiv", "GetVertexAttribivARB", NULL } },
|
||||
{ (PRFuncPtr*) &fHint, { "Hint", NULL } },
|
||||
{ (PRFuncPtr*) &fIsBuffer, { "IsBuffer", "IsBufferARB", NULL } },
|
||||
{ (PRFuncPtr*) &fIsEnabled, { "IsEnabled", NULL } },
|
||||
{ (PRFuncPtr*) &fIsProgram, { "IsProgram", "IsProgramARB", NULL } },
|
||||
{ (PRFuncPtr*) &fIsShader, { "IsShader", "IsShaderARB", NULL } },
|
||||
{ (PRFuncPtr*) &fIsTexture, { "IsTexture", "IsTextureARB", NULL } },
|
||||
{ (PRFuncPtr*) &fLineWidth, { "LineWidth", NULL } },
|
||||
{ (PRFuncPtr*) &fLinkProgram, { "LinkProgram", "LinkProgramARB", NULL } },
|
||||
{ (PRFuncPtr*) &fPixelStorei, { "PixelStorei", NULL } },
|
||||
{ (PRFuncPtr*) &fPolygonOffset, { "PolygonOffset", NULL } },
|
||||
{ (PRFuncPtr*) &fReadPixels, { "ReadPixels", NULL } },
|
||||
{ (PRFuncPtr*) &fSampleCoverage, { "SampleCoverage", NULL } },
|
||||
{ (PRFuncPtr*) &fScissor, { "Scissor", NULL } },
|
||||
{ (PRFuncPtr*) &fStencilFunc, { "StencilFunc", NULL } },
|
||||
{ (PRFuncPtr*) &fStencilFuncSeparate, { "StencilFuncSeparate", "StencilFuncSeparateEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fStencilMask, { "StencilMask", NULL } },
|
||||
{ (PRFuncPtr*) &fStencilMaskSeparate, { "StencilMaskSeparate", "StencilMaskSeparateEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fStencilOp, { "StencilOp", NULL } },
|
||||
{ (PRFuncPtr*) &fStencilOpSeparate, { "StencilOpSeparate", "StencilOpSeparateEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fTexImage2D, { "TexImage2D", NULL } },
|
||||
{ (PRFuncPtr*) &fTexSubImage2D, { "TexSubImage2D", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform1f, { "Uniform1f", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform1fv, { "Uniform1fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform1i, { "Uniform1i", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform1iv, { "Uniform1iv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform2f, { "Uniform2f", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform2fv, { "Uniform2fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform2i, { "Uniform2i", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform2iv, { "Uniform2iv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform3f, { "Uniform3f", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform3fv, { "Uniform3fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform3i, { "Uniform3i", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform3iv, { "Uniform3iv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform4f, { "Uniform4f", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform4fv, { "Uniform4fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform4i, { "Uniform4i", NULL } },
|
||||
{ (PRFuncPtr*) &fUniform4iv, { "Uniform4iv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniformMatrix2fv, { "UniformMatrix2fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniformMatrix3fv, { "UniformMatrix3fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUniformMatrix4fv, { "UniformMatrix4fv", NULL } },
|
||||
{ (PRFuncPtr*) &fUseProgram, { "UseProgram", NULL } },
|
||||
{ (PRFuncPtr*) &fValidateProgram, { "ValidateProgram", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttribPointer, { "VertexAttribPointer", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib1f, { "VertexAttrib1f", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib2f, { "VertexAttrib2f", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib3f, { "VertexAttrib3f", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib4f, { "VertexAttrib4f", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib1fv, { "VertexAttrib1fv", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib2fv, { "VertexAttrib2fv", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib3fv, { "VertexAttrib3fv", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttrib4fv, { "VertexAttrib4fv", NULL } },
|
||||
{ (PRFuncPtr*) &fViewport, { "Viewport", NULL } },
|
||||
{ (PRFuncPtr*) &fCompileShader, { "CompileShader", NULL } },
|
||||
{ (PRFuncPtr*) &fCopyTexImage2D, { "CopyTexImage2D", NULL } },
|
||||
{ (PRFuncPtr*) &fCopyTexSubImage2D, { "CopyTexSubImage2D", NULL } },
|
||||
{ (PRFuncPtr*) &fGetShaderiv, { "GetShaderiv", NULL } },
|
||||
{ (PRFuncPtr*) &fGetShaderInfoLog, { "GetShaderInfoLog", NULL } },
|
||||
{ (PRFuncPtr*) &fGetShaderSource, { "GetShaderSource", NULL } },
|
||||
{ (PRFuncPtr*) &fShaderSource, { "ShaderSource", NULL } },
|
||||
{ (PRFuncPtr*) &fVertexAttribPointer, { "VertexAttribPointer", NULL } },
|
||||
{ (PRFuncPtr*) &fBindFramebuffer, { "BindFramebuffer", "BindFramebufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fBindRenderbuffer, { "BindRenderbuffer", "BindRenderbufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fCheckFramebufferStatus, { "CheckFramebufferStatus", "CheckFramebufferStatusEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fFramebufferRenderbuffer, { "FramebufferRenderbuffer", "FramebufferRenderbufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fFramebufferTexture2D, { "FramebufferTexture2D", "FramebufferTexture2DEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGenerateMipmap, { "GenerateMipmap", "GenerateMipmapEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGenFramebuffers, { "GenFramebuffers", "GenFramebuffersEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGenRenderbuffers, { "GenRenderbuffers", "GenRenderbuffersEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGetFramebufferAttachmentParameteriv, { "GetFramebufferAttachmentParameteriv", "GetFramebufferAttachmentParameterivEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGetRenderbufferParameteriv, { "GetRenderbufferParameteriv", "GetRenderbufferParameterivEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fIsFramebuffer, { "IsFramebuffer", "IsFramebufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fIsRenderbuffer, { "IsRenderbuffer", "IsRenderbufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fRenderbufferStorage, { "RenderbufferStorage", "RenderbufferStorageEXT", NULL } },
|
||||
|
||||
{ NULL, { NULL } },
|
||||
|
||||
};
|
||||
|
||||
ok = LoadSymbols(&symbols[0], trygl, prefix);
|
||||
|
||||
return ok;
|
||||
}
|
|
@ -0,0 +1,388 @@
|
|||
|
||||
#ifndef GLWRAP_H_
|
||||
#define GLWRAP_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "localgl.h"
|
||||
|
||||
#include "prlink.h"
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#ifdef XP_WIN
|
||||
#define GLAPIENTRY __stdcall
|
||||
#else
|
||||
#define GLAPIENTRY
|
||||
#endif
|
||||
#define GLAPI
|
||||
#endif
|
||||
|
||||
class LibrarySymbolLoader
|
||||
{
|
||||
public:
|
||||
bool OpenLibrary(const char *library);
|
||||
|
||||
typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char *);
|
||||
void SetLookupFunc(PlatformLookupFunction plf) {
|
||||
mLookupFunc = plf;
|
||||
}
|
||||
|
||||
enum {
|
||||
MAX_SYMBOL_NAMES = 5,
|
||||
MAX_SYMBOL_LENGTH = 128
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
PRFuncPtr *symPointer;
|
||||
const char *symNames[MAX_SYMBOL_NAMES];
|
||||
} SymLoadStruct;
|
||||
|
||||
PRFuncPtr LookupSymbol(const char *symname, bool tryplatform = false);
|
||||
bool LoadSymbols(SymLoadStruct *firstStruct, bool tryplatform = false, const char *prefix = NULL);
|
||||
|
||||
protected:
|
||||
LibrarySymbolLoader() {
|
||||
mLibrary = NULL;
|
||||
mLookupFunc = NULL;
|
||||
}
|
||||
|
||||
PRLibrary *mLibrary;
|
||||
PlatformLookupFunction mLookupFunc;
|
||||
};
|
||||
|
||||
typedef void *PrivateOSMesaContext;
|
||||
|
||||
class OSMesaWrap
|
||||
: public LibrarySymbolLoader
|
||||
{
|
||||
public:
|
||||
OSMesaWrap() : fCreateContextExt(0) { }
|
||||
|
||||
bool Init();
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// the wrapped functions
|
||||
//
|
||||
public:
|
||||
typedef PrivateOSMesaContext (GLAPIENTRY * PFNOSMESACREATECONTEXTEXT) (GLenum, GLint, GLint, GLint, PrivateOSMesaContext);
|
||||
typedef void (GLAPIENTRY * PFNOSMESADESTROYCONTEXT) (PrivateOSMesaContext);
|
||||
typedef GLboolean (GLAPIENTRY * PFNOSMESAMAKECURRENT) (PrivateOSMesaContext, void *, GLenum, GLsizei, GLsizei);
|
||||
typedef PrivateOSMesaContext (GLAPIENTRY * PFNOSMESAGETCURRENTCONTEXT) (void);
|
||||
typedef void (GLAPIENTRY * PFNOSMESAPIXELSTORE) (GLint, GLint);
|
||||
typedef PRFuncPtr (GLAPIENTRY * PFNOSMESAGETPROCADDRESS) (const char*);
|
||||
|
||||
PFNOSMESACREATECONTEXTEXT fCreateContextExt;
|
||||
PFNOSMESADESTROYCONTEXT fDestroyContext;
|
||||
PFNOSMESAMAKECURRENT fMakeCurrent;
|
||||
PFNOSMESAGETCURRENTCONTEXT fGetCurrentContext;
|
||||
PFNOSMESAPIXELSTORE fPixelStore;
|
||||
PFNOSMESAGETPROCADDRESS fGetProcAddress;
|
||||
};
|
||||
|
||||
class GLES20Wrap
|
||||
: public LibrarySymbolLoader
|
||||
{
|
||||
public:
|
||||
enum NativeGLMode {
|
||||
TRY_NATIVE_GL = 1 << 0,
|
||||
TRY_SOFTWARE_GL = 1 << 1
|
||||
};
|
||||
|
||||
GLES20Wrap() : ok(false) { }
|
||||
|
||||
bool Init(NativeGLMode mode);
|
||||
|
||||
protected:
|
||||
|
||||
bool ok;
|
||||
|
||||
bool InitNative();
|
||||
bool InitSoftware();
|
||||
|
||||
bool InitWithPrefix(const char *prefix, bool trygl );
|
||||
|
||||
//
|
||||
// the wrapped functions
|
||||
//
|
||||
public:
|
||||
/* One would think that this would live in some nice perl-or-python-or-js script somewhere and would be autogenerated;
|
||||
* one would be wrong.
|
||||
*/
|
||||
typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture);
|
||||
PFNGLACTIVETEXTUREPROC fActiveTexture;
|
||||
typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
|
||||
PFNGLATTACHSHADERPROC fAttachShader;
|
||||
typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name);
|
||||
PFNGLBINDATTRIBLOCATIONPROC fBindAttribLocation;
|
||||
typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||
PFNGLBINDBUFFERPROC fBindBuffer;
|
||||
typedef void (GLAPIENTRY * PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
|
||||
PFNGLBINDTEXTUREPROC fBindTexture;
|
||||
typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
PFNGLBLENDCOLORPROC fBlendColor;
|
||||
typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode);
|
||||
PFNGLBLENDEQUATIONPROC fBlendEquation;
|
||||
typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum);
|
||||
PFNGLBLENDEQUATIONSEPARATEPROC fBlendEquationSeparate;
|
||||
typedef void (GLAPIENTRY * PFNGLBLENDFUNCPROC) (GLenum, GLenum);
|
||||
PFNGLBLENDFUNCPROC fBlendFunc;
|
||||
typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
|
||||
PFNGLBLENDFUNCSEPARATEPROC fBlendFuncSeparate;
|
||||
typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
|
||||
PFNGLBUFFERDATAPROC fBufferData;
|
||||
typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
|
||||
PFNGLBUFFERSUBDATAPROC fBufferSubData;
|
||||
typedef void (GLAPIENTRY * PFNGLCLEARPROC) (GLbitfield);
|
||||
PFNGLCLEARPROC fClear;
|
||||
typedef void (GLAPIENTRY * PFNGLCLEARCOLORPROC) (GLclampf, GLclampf, GLclampf, GLclampf);
|
||||
PFNGLCLEARCOLORPROC fClearColor;
|
||||
typedef void (GLAPIENTRY * PFNGLCLEARDEPTHPROC) (GLclampd);
|
||||
PFNGLCLEARDEPTHPROC fClearDepth;
|
||||
typedef void (GLAPIENTRY * PFNGLCLEARSTENCILPROC) (GLint);
|
||||
PFNGLCLEARSTENCILPROC fClearStencil;
|
||||
typedef void (GLAPIENTRY * PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||
PFNGLCOLORMASKPROC fColorMask;
|
||||
typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void);
|
||||
PFNGLCREATEPROGRAMPROC fCreateProgram;
|
||||
typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type);
|
||||
PFNGLCREATESHADERPROC fCreateShader;
|
||||
typedef void (GLAPIENTRY * PFNGLCULLFACEPROC) (GLenum mode);
|
||||
PFNGLCULLFACEPROC fCullFace;
|
||||
typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);
|
||||
PFNGLDELETEBUFFERSPROC fDeleteBuffers;
|
||||
typedef void (GLAPIENTRY * PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint* textures);
|
||||
PFNGLDELETETEXTURESPROC fDeleteTextures;
|
||||
typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program);
|
||||
PFNGLDELETEPROGRAMPROC fDeleteProgram;
|
||||
typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader);
|
||||
PFNGLDELETESHADERPROC fDeleteShader;
|
||||
typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
|
||||
PFNGLDETACHSHADERPROC fDetachShader;
|
||||
typedef void (GLAPIENTRY * PFNGLDEPTHFUNCPROC) (GLenum);
|
||||
PFNGLDEPTHFUNCPROC fDepthFunc;
|
||||
typedef void (GLAPIENTRY * PFNGLDEPTHMASKPROC) (GLboolean);
|
||||
PFNGLDEPTHMASKPROC fDepthMask;
|
||||
typedef void (GLAPIENTRY * PFNGLDEPTHRANGEPROC) (GLclampd, GLclampd);
|
||||
PFNGLDEPTHRANGEPROC fDepthRange;
|
||||
typedef void (GLAPIENTRY * PFNGLDISABLEPROC) (GLenum);
|
||||
PFNGLDISABLEPROC fDisable;
|
||||
typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
|
||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC fDisableVertexAttribArray;
|
||||
typedef void (GLAPIENTRY * PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count);
|
||||
PFNGLDRAWARRAYSPROC fDrawArrays;
|
||||
typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
||||
PFNGLDRAWELEMENTSPROC fDrawElements;
|
||||
typedef void (GLAPIENTRY * PFNGLENABLEPROC) (GLenum);
|
||||
PFNGLENABLEPROC fEnable;
|
||||
typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint);
|
||||
PFNGLENABLEVERTEXATTRIBARRAYPROC fEnableVertexAttribArray;
|
||||
typedef void (GLAPIENTRY * PFNGLFINISHPROC) (void);
|
||||
PFNGLFINISHPROC fFinish;
|
||||
typedef void (GLAPIENTRY * PFNGLFLUSHPROC) (void);
|
||||
PFNGLFLUSHPROC fFlush;
|
||||
typedef void (GLAPIENTRY * PFNGLFRONTFACEPROC) (GLenum);
|
||||
PFNGLFRONTFACEPROC fFrontFace;
|
||||
typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
|
||||
PFNGLGETACTIVEATTRIBPROC fGetActiveAttrib;
|
||||
typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
|
||||
PFNGLGETACTIVEUNIFORMPROC fGetActiveUniform;
|
||||
typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);
|
||||
PFNGLGETATTACHEDSHADERSPROC fGetAttachedShaders;
|
||||
typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name);
|
||||
PFNGLGETATTRIBLOCATIONPROC fGetAttribLocation;
|
||||
typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
|
||||
PFNGLGETINTEGERVPROC fGetIntegerv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params);
|
||||
PFNGLGETDOUBLEVPROC fGetDoublev;
|
||||
typedef void (GLAPIENTRY * PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params);
|
||||
PFNGLGETFLOATVPROC fGetFloatv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETBOOLEANBPROC) (GLenum pname, GLboolean *params);
|
||||
PFNGLGETBOOLEANBPROC fGetBooleanv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);
|
||||
PFNGLGETBUFFERPARAMETERIVPROC fGetBufferParameteriv;
|
||||
typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers);
|
||||
PFNGLGENBUFFERSPROC fGenBuffers;
|
||||
typedef void (GLAPIENTRY * PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
|
||||
PFNGLGENTEXTURESPROC fGenTextures;
|
||||
typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target);
|
||||
PFNGLGENERATEMIPMAPPROC fGenerateMipmap;
|
||||
typedef GLenum (GLAPIENTRY * PFNGLGETERRORPROC) (void);
|
||||
PFNGLGETERRORPROC fGetError;
|
||||
typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param);
|
||||
PFNGLGETPROGRAMIVPROC fGetProgramiv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
|
||||
PFNGLGETPROGRAMINFOLOGPROC fGetProgramInfoLog;
|
||||
typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
|
||||
PFNGLTEXPARAMETERIPROC fTexParameteri;
|
||||
typedef void (GLAPIENTRY * PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
|
||||
PFNGLTEXPARAMETERFPROC fTexParameterf;
|
||||
typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
|
||||
PFNGLTEXPARAMETERIVPROC fGetTexParameteriv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params);
|
||||
PFNGLGETUNIFORMFVPROC fGetUniformfv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params);
|
||||
PFNGLGETUNIFORMIVPROC fGetUniformiv;
|
||||
typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name);
|
||||
PFNGLGETUNIFORMLOCATIONPROC fGetUniformLocation;
|
||||
typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*);
|
||||
PFNGLGETVERTEXATTRIBDVPROC fGetVertexAttribdv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*);
|
||||
PFNGLGETVERTEXATTRIBFVPROC fGetVertexAttribfv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*);
|
||||
PFNGLGETVERTEXATTRIBIVPROC fGetVertexAttribiv;
|
||||
typedef void (GLAPIENTRY * PFNGLHINTPROC) (GLenum target, GLenum mode);
|
||||
PFNGLHINTPROC fHint;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer);
|
||||
PFNGLISBUFFERPROC fIsBuffer;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDPROC) (GLenum cap);
|
||||
PFNGLISENABLEDPROC fIsEnabled;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program);
|
||||
PFNGLISPROGRAMPROC fIsProgram;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader);
|
||||
PFNGLISSHADERPROC fIsShader;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREPROC) (GLuint texture);
|
||||
PFNGLISTEXTUREPROC fIsTexture;
|
||||
typedef void (GLAPIENTRY * PFNGLLINEWIDTHPROC) (GLfloat width);
|
||||
PFNGLLINEWIDTHPROC fLineWidth;
|
||||
typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program);
|
||||
PFNGLLINKPROGRAMPROC fLinkProgram;
|
||||
typedef void (GLAPIENTRY * PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
|
||||
PFNGLPIXELSTOREIPROC fPixelStorei;
|
||||
typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat bias);
|
||||
PFNGLPOLYGONOFFSETPROC fPolygonOffset;
|
||||
typedef void (GLAPIENTRY * PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
|
||||
PFNGLREADPIXELSPROC fReadPixels;
|
||||
typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
|
||||
PFNGLSAMPLECOVERAGEPROC fSampleCoverage;
|
||||
typedef void (GLAPIENTRY * PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
PFNGLSCISSORPROC fScissor;
|
||||
typedef void (GLAPIENTRY * PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask);
|
||||
PFNGLSTENCILFUNCPROC fStencilFunc;
|
||||
typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
|
||||
PFNGLSTENCILFUNCSEPARATEPROC fStencilFuncSeparate;
|
||||
typedef void (GLAPIENTRY * PFNGLSTENCILMASKPROC) (GLuint mask);
|
||||
PFNGLSTENCILMASKPROC fStencilMask;
|
||||
typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint);
|
||||
PFNGLSTENCILMASKSEPARATEPROC fStencilMaskSeparate;
|
||||
typedef void (GLAPIENTRY * PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass);
|
||||
PFNGLSTENCILOPPROC fStencilOp;
|
||||
typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
PFNGLSTENCILOPSEPARATEPROC fStencilOpSeparate;
|
||||
typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
PFNGLTEXIMAGE2DPROC fTexImage2D;
|
||||
typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
|
||||
PFNGLTEXSUBIMAGE2DPROC fTexSubImage2D;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
|
||||
PFNGLUNIFORM1FPROC fUniform1f;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value);
|
||||
PFNGLUNIFORM1FVPROC fUniform1fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
|
||||
PFNGLUNIFORM1IPROC fUniform1i;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value);
|
||||
PFNGLUNIFORM1IVPROC fUniform1iv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
|
||||
PFNGLUNIFORM2FPROC fUniform2f;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value);
|
||||
PFNGLUNIFORM2FVPROC fUniform2fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
|
||||
PFNGLUNIFORM2IPROC fUniform2i;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value);
|
||||
PFNGLUNIFORM2IVPROC fUniform2iv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
|
||||
PFNGLUNIFORM3FPROC fUniform3f;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value);
|
||||
PFNGLUNIFORM3FVPROC fUniform3fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
|
||||
PFNGLUNIFORM3IPROC fUniform3i;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value);
|
||||
PFNGLUNIFORM3IVPROC fUniform3iv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||
PFNGLUNIFORM4FPROC fUniform4f;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value);
|
||||
PFNGLUNIFORM4FVPROC fUniform4fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
|
||||
PFNGLUNIFORM4IPROC fUniform4i;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value);
|
||||
PFNGLUNIFORM4IVPROC fUniform4iv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
PFNGLUNIFORMMATRIX2FVPROC fUniformMatrix2fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
PFNGLUNIFORMMATRIX3FVPROC fUniformMatrix3fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
PFNGLUNIFORMMATRIX4FVPROC fUniformMatrix4fv;
|
||||
typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program);
|
||||
PFNGLUSEPROGRAMPROC fUseProgram;
|
||||
typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program);
|
||||
PFNGLVALIDATEPROGRAMPROC fValidateProgram;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
|
||||
PFNGLVERTEXATTRIBPOINTERPROC fVertexAttribPointer;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
|
||||
PFNGLVERTEXATTRIB1FPROC fVertexAttrib1f;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
|
||||
PFNGLVERTEXATTRIB2FPROC fVertexAttrib2f;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
|
||||
PFNGLVERTEXATTRIB3FPROC fVertexAttrib3f;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
|
||||
PFNGLVERTEXATTRIB4FPROC fVertexAttrib4f;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v);
|
||||
PFNGLVERTEXATTRIB1FVPROC fVertexAttrib1fv;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v);
|
||||
PFNGLVERTEXATTRIB2FVPROC fVertexAttrib2fv;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v);
|
||||
PFNGLVERTEXATTRIB3FVPROC fVertexAttrib3fv;
|
||||
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v);
|
||||
PFNGLVERTEXATTRIB4FVPROC fVertexAttrib4fv;
|
||||
typedef void (GLAPIENTRY * PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
PFNGLVIEWPORTPROC fViewport;
|
||||
typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader);
|
||||
PFNGLCOMPILESHADERPROC fCompileShader;
|
||||
typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
||||
PFNGLCOPYTEXIMAGE2DPROC fCopyTexImage2D;
|
||||
typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
PFNGLCOPYTEXSUBIMAGE2DPROC fCopyTexSubImage2D;
|
||||
typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param);
|
||||
PFNGLGETSHADERIVPROC fGetShaderiv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
|
||||
PFNGLGETSHADERINFOLOGPROC fGetShaderInfoLog;
|
||||
typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source);
|
||||
PFNGLGETSHADERSOURCEPROC fGetShaderSource;
|
||||
typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths);
|
||||
PFNGLSHADERSOURCEPROC fShaderSource;
|
||||
|
||||
typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFER) (GLenum target, GLuint framebuffer);
|
||||
PFNGLBINDFRAMEBUFFER fBindFramebuffer;
|
||||
typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFER) (GLenum target, GLuint renderbuffer);
|
||||
PFNGLBINDRENDERBUFFER fBindRenderbuffer;
|
||||
typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUS) (GLenum target);
|
||||
PFNGLCHECKFRAMEBUFFERSTATUS fCheckFramebufferStatus;
|
||||
typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERS) (GLsizei n, const GLuint* ids);
|
||||
PFNGLDELETEFRAMEBUFFERS fDeleteFramebuffers;
|
||||
typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERS) (GLsizei n, const GLuint* ids);
|
||||
PFNGLDELETERENDERBUFFERS fDeleteRenderbuffers;
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFER) (GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer);
|
||||
PFNGLFRAMEBUFFERRENDERBUFFER fFramebufferRenderbuffer;
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2D) (GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level);
|
||||
PFNGLFRAMEBUFFERTEXTURE2D fFramebufferTexture2D;
|
||||
typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV) (GLenum target, GLenum attachment, GLenum pname, GLint* value);
|
||||
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV fGetFramebufferAttachmentParameteriv;
|
||||
typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIV) (GLenum target, GLenum pname, GLint* value);
|
||||
PFNGLGETRENDERBUFFERPARAMETERIV fGetRenderbufferParameteriv;
|
||||
typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERS) (GLsizei n, GLuint* ids);
|
||||
PFNGLGENFRAMEBUFFERS fGenFramebuffers;
|
||||
typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERS) (GLsizei n, GLuint* ids);
|
||||
PFNGLGENRENDERBUFFERS fGenRenderbuffers;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFER) (GLuint framebuffer);
|
||||
PFNGLISFRAMEBUFFER fIsFramebuffer;
|
||||
typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFER) (GLuint renderbuffer);
|
||||
PFNGLISRENDERBUFFER fIsRenderbuffer;
|
||||
typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
|
||||
PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -3243,22 +3243,6 @@ nsCanvasRenderingContext2D::ConvertJSValToXPCObject(nsISupports** aSupports, REF
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* Check that the rect [x,y,w,h] is a valid subrect of [0,0,realWidth,realHeight]
|
||||
* without overflowing any integers and the like.
|
||||
*/
|
||||
PRBool
|
||||
CheckSaneSubrectSize (PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h, PRInt32 realWidth, PRInt32 realHeight)
|
||||
{
|
||||
if (w <= 0 || h <= 0 || x < 0 || y < 0)
|
||||
return PR_FALSE;
|
||||
|
||||
if (x >= realWidth || w > (realWidth - x) ||
|
||||
y >= realHeight || h > (realHeight - y))
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
FlushLayoutForTree(nsIDOMWindow* aWindow)
|
||||
{
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,425 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 _NSCANVASRENDERINGCONTEXTGL_H_
|
||||
#define _NSCANVASRENDERINGCONTEXTGL_H_
|
||||
|
||||
#ifdef C3D_STANDALONE_BUILD
|
||||
#include "c3d-standalone.h"
|
||||
#endif
|
||||
|
||||
#include "nsICanvasRenderingContextGL.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
#include "nsICanvasRenderingContextGLBuffer.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
#include "nsIDOMHTMLCanvasElement.h"
|
||||
|
||||
#include "nsICanvasGLPrivate.h"
|
||||
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIDOMHTMLCanvasElement.h"
|
||||
#include "nsICanvasElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIConsoleService.h"
|
||||
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
|
||||
extern nsIXPConnect *gXPConnect;
|
||||
extern JSRuntime *gScriptRuntime;
|
||||
extern nsIJSRuntimeService *gJSRuntimeService;
|
||||
|
||||
class nsICanvasRenderingContextGL;
|
||||
|
||||
class nsCanvasRenderingContextGLES11;
|
||||
class nsCanvasRenderingContextGLWeb20;
|
||||
|
||||
class CanvasGLBuffer;
|
||||
class CanvasGLTexture;
|
||||
|
||||
class nsCanvasRenderingContextGLPrivate :
|
||||
public nsICanvasRenderingContextInternal,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsGLPbuffer;
|
||||
friend class CanvasGLBuffer;
|
||||
friend class CanvasGLTexture;
|
||||
|
||||
public:
|
||||
nsCanvasRenderingContextGLPrivate();
|
||||
virtual ~nsCanvasRenderingContextGLPrivate();
|
||||
|
||||
virtual nsICanvasRenderingContextGL *GetSelf() = 0;
|
||||
|
||||
virtual PRBool ValidateGL() { return PR_TRUE; }
|
||||
|
||||
void MakeContextCurrent();
|
||||
static void LostCurrentContext(void *closure);
|
||||
|
||||
// nsICanvasRenderingContextInternal
|
||||
NS_IMETHOD SetCanvasElement(nsICanvasElement* aParentCanvas);
|
||||
NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
|
||||
NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter f);
|
||||
NS_IMETHOD GetInputStream(const char* aMimeType,
|
||||
const PRUnichar* aEncoderOptions,
|
||||
nsIInputStream **aStream);
|
||||
NS_IMETHOD GetThebesSurface(gfxASurface **surface);
|
||||
NS_IMETHOD SetIsOpaque(PRBool b) { return NS_OK; };
|
||||
|
||||
protected:
|
||||
PRBool SafeToCreateCanvas3DContext(nsICanvasElement *canvasElement);
|
||||
nsresult DoSwapBuffers();
|
||||
|
||||
// thebes helpers
|
||||
nsresult ImageSurfaceFromElement(nsIDOMElement *imgElt,
|
||||
gfxImageSurface **aSurface,
|
||||
nsIPrincipal **prinOut,
|
||||
PRBool *forceWriteOnlyOut,
|
||||
PRBool *surfaceNeedsReleaseInsteadOfDelete);
|
||||
|
||||
void DoDrawImageSecurityCheck(nsIPrincipal* element_uri, PRBool forceWriteOnly);
|
||||
|
||||
GLES20Wrap *gl;
|
||||
|
||||
nsGLPbuffer *mGLPbuffer;
|
||||
PRInt32 mWidth, mHeight;
|
||||
nsICanvasElement* mCanvasElement;
|
||||
|
||||
PRPackedBool mPrefWireframe;
|
||||
|
||||
void LogMessage (const nsCString& errorString) {
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (!console)
|
||||
return;
|
||||
|
||||
console->LogStringMessage(NS_ConvertUTF8toUTF16(errorString).get());
|
||||
fprintf(stderr, "%s\n", errorString.get());
|
||||
}
|
||||
|
||||
void LogMessagef (const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char buf[256];
|
||||
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (console) {
|
||||
vsnprintf(buf, 256, fmt, ap);
|
||||
console->LogStringMessage(NS_ConvertUTF8toUTF16(nsDependentCString(buf)).get());
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SimpleBuffer {
|
||||
public:
|
||||
SimpleBuffer()
|
||||
: type(GL_FLOAT), data(nsnull), length(0), capacity(0), sizePerVertex(0)
|
||||
{ }
|
||||
|
||||
SimpleBuffer(PRUint32 typeParam,
|
||||
PRUint32 sizeParam,
|
||||
JSContext *ctx,
|
||||
JSObject *arrayObj,
|
||||
jsuint arrayLen)
|
||||
: type(GL_FLOAT), data(nsnull), length(0), capacity(0), sizePerVertex(0)
|
||||
{
|
||||
InitFromJSArray(typeParam, sizeParam, ctx, arrayObj, arrayLen);
|
||||
}
|
||||
|
||||
PRBool InitFromJSArray(PRUint32 typeParam,
|
||||
PRUint32 sizeParam,
|
||||
JSContext *ctx,
|
||||
JSObject *arrayObj,
|
||||
jsuint arrayLen);
|
||||
|
||||
~SimpleBuffer() {
|
||||
Release();
|
||||
}
|
||||
|
||||
inline PRBool Valid() {
|
||||
return data != nsnull;
|
||||
}
|
||||
|
||||
inline PRUint32 ElementSize() {
|
||||
if (type == GL_FLOAT) return sizeof(float);
|
||||
if (type == GL_SHORT) return sizeof(short);
|
||||
if (type == GL_UNSIGNED_SHORT) return sizeof(unsigned short);
|
||||
if (type == GL_BYTE) return 1;
|
||||
if (type == GL_UNSIGNED_BYTE) return 1;
|
||||
if (type == GL_INT) return sizeof(int);
|
||||
if (type == GL_UNSIGNED_INT) return sizeof(unsigned int);
|
||||
if (type == GL_DOUBLE) return sizeof(double);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Set(PRUint32 t, PRUint32 spv, PRUint32 count, void* vals) {
|
||||
Prepare(t, spv, count);
|
||||
|
||||
if (count)
|
||||
memcpy(data, vals, count*ElementSize());
|
||||
}
|
||||
|
||||
void Prepare(PRUint32 t, PRUint32 spv, PRUint32 count) {
|
||||
if (count == 0) {
|
||||
Release();
|
||||
} else {
|
||||
type = t;
|
||||
EnsureCapacity(PR_FALSE, count*ElementSize());
|
||||
length = count;
|
||||
sizePerVertex = spv;
|
||||
}
|
||||
}
|
||||
|
||||
void Release() {
|
||||
if (data)
|
||||
PR_Free(data);
|
||||
length = 0;
|
||||
capacity = 0;
|
||||
data = nsnull;
|
||||
}
|
||||
|
||||
void EnsureCapacity(PRBool preserve, PRUint32 cap) {
|
||||
if (capacity >= cap)
|
||||
return;
|
||||
|
||||
void* newdata = PR_Malloc(cap);
|
||||
if (preserve && length)
|
||||
memcpy(newdata, data, length*ElementSize());
|
||||
PR_Free(data);
|
||||
data = newdata;
|
||||
capacity = cap;
|
||||
}
|
||||
|
||||
PRUint32 type;
|
||||
void* data;
|
||||
PRUint32 length; // # of elements
|
||||
PRUint32 capacity; // bytes!
|
||||
PRUint32 sizePerVertex; // OpenGL "size" param; num coordinates per vertex
|
||||
};
|
||||
|
||||
class CanvasGLTexture :
|
||||
public nsICanvasRenderingContextGLTexture,
|
||||
public nsICanvasGLTexture
|
||||
{
|
||||
friend class nsCanvasRenderingContextGLES11;
|
||||
friend class nsCanvasRenderingContextGLWeb20;
|
||||
public:
|
||||
CanvasGLTexture(nsCanvasRenderingContextGLPrivate *owner);
|
||||
~CanvasGLTexture();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSICANVASRENDERINGCONTEXTGLTEXTURE
|
||||
|
||||
nsresult Init();
|
||||
nsresult Dispose();
|
||||
|
||||
protected:
|
||||
PRBool mDisposed;
|
||||
nsCOMPtr<nsIWeakReference> mOwnerContext;
|
||||
|
||||
GLES20Wrap *gl;
|
||||
|
||||
PRUint32 mWidth;
|
||||
PRUint32 mHeight;
|
||||
};
|
||||
|
||||
class CanvasGLBuffer :
|
||||
public nsICanvasRenderingContextGLBuffer,
|
||||
public nsISecurityCheckedComponent,
|
||||
public nsICanvasGLBuffer
|
||||
{
|
||||
friend class nsCanvasRenderingContextGLES11;
|
||||
friend class nsCanvasRenderingContextGLWeb20;
|
||||
public:
|
||||
|
||||
CanvasGLBuffer(nsCanvasRenderingContextGLPrivate *owner);
|
||||
~CanvasGLBuffer();
|
||||
|
||||
// Init can be called multiple times to reinitialize this
|
||||
// buffer object
|
||||
nsresult Init (PRUint32 usage,
|
||||
PRUint32 size,
|
||||
PRUint32 type,
|
||||
JSContext *ctx,
|
||||
JSObject *arrayObj,
|
||||
jsuint arrayLen);
|
||||
|
||||
SimpleBuffer& GetSimpleBuffer() { return mSimpleBuffer; }
|
||||
PRBool UpdateBuffer (PRUint32 offset, SimpleBuffer& sbuffer)
|
||||
{
|
||||
PRUint32 len = GetSimpleBuffer().capacity;
|
||||
PRUint32 sbuflen = sbuffer.capacity;
|
||||
if (offset < 0 || offset > len || sbuflen > len || offset > len - sbuflen)
|
||||
return false;
|
||||
memcpy(((char*)(GetSimpleBuffer().data)) + offset, sbuffer.data, sbuflen);
|
||||
mMaxUShortComputed = false;
|
||||
return true;
|
||||
}
|
||||
GLushort MaxUShortValue()
|
||||
{
|
||||
if (!mMaxUShortComputed) {
|
||||
GLushort *data = (GLushort*)GetSimpleBuffer().data;
|
||||
PRUint32 i, len;
|
||||
GLushort max = 0;
|
||||
len = GetSimpleBuffer().capacity / sizeof(GLushort);
|
||||
for (i=0; i<len; ++i)
|
||||
if (data[i] > max)
|
||||
max = data[i];
|
||||
mMaxUShort = max;
|
||||
mMaxUShortComputed = true;
|
||||
}
|
||||
return mMaxUShort;
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICANVASRENDERINGCONTEXTGLBUFFER
|
||||
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
||||
|
||||
PRUint32 Size() { return mSize; }
|
||||
PRUint32 Length() { return mLength; }
|
||||
PRUint32 Type() { return mType; }
|
||||
|
||||
protected:
|
||||
CanvasGLBuffer() { }
|
||||
|
||||
nsCOMPtr<nsIWeakReference> mOwnerContext;
|
||||
|
||||
GLES20Wrap *gl;
|
||||
|
||||
PRBool mDisposed;
|
||||
|
||||
PRUint32 mLength;
|
||||
PRUint32 mSize;
|
||||
PRUint32 mType;
|
||||
PRUint32 mUsage;
|
||||
|
||||
SimpleBuffer mSimpleBuffer;
|
||||
GLuint mBufferID;
|
||||
|
||||
GLushort mMaxUShort;
|
||||
PRBool mMaxUShortComputed;
|
||||
};
|
||||
|
||||
class CanvasGLThebes {
|
||||
public:
|
||||
static gfxImageSurface *CreateImageSurface (const gfxIntSize &isize,
|
||||
gfxASurface::gfxImageFormat fmt);
|
||||
|
||||
static gfxContext *CreateContext (gfxASurface *surf);
|
||||
|
||||
static gfxPattern *CreatePattern (gfxASurface *surf);
|
||||
};
|
||||
|
||||
/* Helper macros for when we're just wrapping a gl method, so that
|
||||
* we can avoid having to type this 500 times. Note that these MUST
|
||||
* NOT BE USED if we need to check any of the parameters.
|
||||
*/
|
||||
|
||||
#define GL_SAME_METHOD_0(glname, name) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name() { \
|
||||
MakeContextCurrent(); gl->f##glname(); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_1(glname, name, t1) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_2(glname, name, t1, t2) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_3(glname, name, t1, t2, t3) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_4(glname, name, t1, t2, t3, t4) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_5(glname, name, t1, t2, t3, t4, t5) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4,a5); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_6(glname, name, t1, t2, t3, t4, t5, t6) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4,a5,a6); return NS_OK; \
|
||||
}
|
||||
|
||||
#endif /* _NSCANVASRENDERINGCONTEXTGL_H_ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,147 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "nsCanvasRenderingContextGL.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
|
||||
#if 0
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
void *nsGLPbuffer::sCurrentContextToken = nsnull;
|
||||
|
||||
void
|
||||
nsGLPbuffer::LogMessage (const nsCString& errorString)
|
||||
{
|
||||
if (mPriv)
|
||||
mPriv->LogMessage(errorString);
|
||||
else
|
||||
fprintf(stderr, "nsGLPbuffer: %s\n", errorString.get());
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbuffer::LogMessagef (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char buf[256];
|
||||
|
||||
vsnprintf(buf, 256, fmt, ap);
|
||||
|
||||
if (mPriv)
|
||||
mPriv->LogMessage(nsDependentCString(buf));
|
||||
else
|
||||
fprintf(stderr, "nsGLPbuffer: %s\n", buf);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void
|
||||
premultiply_slow(unsigned char *src, unsigned int len)
|
||||
{
|
||||
int a,t;
|
||||
for (unsigned int i=0; i<len; i+=4) {
|
||||
a = src[i+3];
|
||||
t = src[i]*a+0x80;
|
||||
src[i] = ((t>>8) + t) >> 8;
|
||||
t = src[i+1]*a+0x80;
|
||||
src[i+1] = ((t>>8) + t) >> 8;
|
||||
t = src[i+2]*a+0x80;
|
||||
src[i+2] = ((t>>8) + t) >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
premultiply_sse2(__m128i* block, __m128i* block_end)
|
||||
{
|
||||
__m128i xmm0080, xmm0101, xmmAlpha, data, dataLo, dataHi, alphaLo, alphaHi;
|
||||
while (block < block_end) {
|
||||
xmm0080 = _mm_set1_epi16(0x0080);
|
||||
xmm0101 = _mm_set1_epi16(0x0101);
|
||||
xmmAlpha = _mm_set_epi32(0x00ff0000, 0x00000000, 0x00ff0000, 0x00000000);
|
||||
|
||||
data = _mm_loadu_si128(block);
|
||||
dataLo = _mm_unpacklo_epi8 (data, _mm_setzero_si128 ());
|
||||
dataHi = _mm_unpackhi_epi8 (data, _mm_setzero_si128 ());
|
||||
|
||||
alphaLo = _mm_shufflelo_epi16 (dataLo, _MM_SHUFFLE(3, 3, 3, 3));
|
||||
alphaHi = _mm_shufflelo_epi16 (dataHi, _MM_SHUFFLE(3, 3, 3, 3));
|
||||
alphaLo = _mm_shufflehi_epi16 (alphaLo, _MM_SHUFFLE(3, 3, 3, 3));
|
||||
alphaHi = _mm_shufflehi_epi16 (alphaHi, _MM_SHUFFLE(3, 3, 3, 3));
|
||||
|
||||
alphaLo = _mm_or_si128(alphaLo, xmmAlpha);
|
||||
alphaHi = _mm_or_si128(alphaHi, xmmAlpha);
|
||||
|
||||
dataLo = _mm_shufflelo_epi16 (dataLo, _MM_SHUFFLE(3, 2, 1, 0));
|
||||
dataLo = _mm_shufflehi_epi16 (dataLo, _MM_SHUFFLE(3, 2, 1, 0));
|
||||
dataHi = _mm_shufflelo_epi16 (dataHi, _MM_SHUFFLE(3, 2, 1, 0));
|
||||
dataHi = _mm_shufflehi_epi16 (dataHi, _MM_SHUFFLE(3, 2, 1, 0));
|
||||
|
||||
dataLo = _mm_mullo_epi16(dataLo, alphaLo);
|
||||
dataHi = _mm_mullo_epi16(dataHi, alphaHi);
|
||||
|
||||
dataLo = _mm_adds_epu16(dataLo, xmm0080);
|
||||
dataHi = _mm_adds_epu16(dataHi, xmm0080);
|
||||
|
||||
dataLo = _mm_mulhi_epu16(dataLo, xmm0101);
|
||||
dataHi = _mm_mulhi_epu16(dataHi, xmm0101);
|
||||
|
||||
data = _mm_packus_epi16 (dataLo, dataHi);
|
||||
_mm_storeu_si128(block, data);
|
||||
|
||||
++block;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsGLPbuffer::Premultiply(unsigned char *src, unsigned int len)
|
||||
{
|
||||
#if 0
|
||||
if (can_sse2) {
|
||||
premultiply_sse2((__m128i*)src, (__m128i*)(src+len));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
premultiply_slow(src, len);
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 NSGLPBUFFER_H_
|
||||
#define NSGLPBUFFER_H_
|
||||
|
||||
#ifdef C3D_STANDALONE_BUILD
|
||||
#include "c3d-standalone.h"
|
||||
#endif
|
||||
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "gfxWindowsSurface.h"
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) && defined(MOZ_X11)
|
||||
#include "GL/glx.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "gfxQuartzImageSurface.h"
|
||||
#include <OpenGL/CGLTypes.h>
|
||||
#endif
|
||||
|
||||
#include "glwrap.h"
|
||||
|
||||
class nsCanvasRenderingContextGLPrivate;
|
||||
|
||||
class nsGLPbuffer {
|
||||
public:
|
||||
nsGLPbuffer() : mWidth(0), mHeight(0), mPriv(0) { }
|
||||
virtual ~nsGLPbuffer() { }
|
||||
|
||||
virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv) = 0;
|
||||
virtual PRBool Resize(PRInt32 width, PRInt32 height) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual void MakeContextCurrent() = 0;
|
||||
virtual void SwapBuffers() = 0;
|
||||
|
||||
virtual gfxASurface* ThebesSurface() = 0;
|
||||
|
||||
PRInt32 Width() { return mWidth; }
|
||||
PRInt32 Height() { return mHeight; }
|
||||
|
||||
GLES20Wrap *GL() { return &mGLWrap; }
|
||||
|
||||
protected:
|
||||
PRInt32 mWidth, mHeight;
|
||||
|
||||
GLES20Wrap mGLWrap;
|
||||
|
||||
static void *sCurrentContextToken;
|
||||
nsCanvasRenderingContextGLPrivate *mPriv;
|
||||
|
||||
void Premultiply(unsigned char *src, unsigned int len);
|
||||
|
||||
void LogMessage (const nsCString& errorString);
|
||||
void LogMessagef (const char *fmt, ...);
|
||||
};
|
||||
|
||||
class nsGLPbufferOSMESA :
|
||||
public nsGLPbuffer
|
||||
{
|
||||
public:
|
||||
nsGLPbufferOSMESA();
|
||||
virtual ~nsGLPbufferOSMESA();
|
||||
|
||||
virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
|
||||
virtual PRBool Resize(PRInt32 width, PRInt32 height);
|
||||
virtual void Destroy();
|
||||
|
||||
virtual void MakeContextCurrent();
|
||||
virtual void SwapBuffers();
|
||||
|
||||
virtual gfxASurface* ThebesSurface();
|
||||
|
||||
protected:
|
||||
nsRefPtr<gfxImageSurface> mThebesSurface;
|
||||
PrivateOSMesaContext mMesaContext;
|
||||
};
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
class nsGLPbufferCGL :
|
||||
public nsGLPbuffer
|
||||
{
|
||||
public:
|
||||
nsGLPbufferCGL();
|
||||
virtual ~nsGLPbufferCGL();
|
||||
|
||||
virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
|
||||
virtual PRBool Resize(PRInt32 width, PRInt32 height);
|
||||
virtual void Destroy();
|
||||
|
||||
virtual void MakeContextCurrent();
|
||||
virtual void SwapBuffers();
|
||||
|
||||
virtual gfxASurface* ThebesSurface();
|
||||
|
||||
CGLPixelFormatObj GetCGLPixelFormat() { return mPixelFormat; }
|
||||
CGLContextObj GetCGLContext() { return mContext; }
|
||||
CGLPBufferObj GetCGLPbuffer() { return mPbuffer; }
|
||||
|
||||
protected:
|
||||
CGLPixelFormatObj mPixelFormat;
|
||||
CGLContextObj mContext;
|
||||
CGLPBufferObj mPbuffer;
|
||||
|
||||
PRBool mImageNeedsUpdate;
|
||||
nsRefPtr<gfxImageSurface> mThebesSurface;
|
||||
nsRefPtr<gfxQuartzImageSurface> mQuartzSurface;
|
||||
|
||||
typedef void (GLAPIENTRY * PFNGLFLUSHPROC) (void);
|
||||
PFNGLFLUSHPROC fFlush;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) && defined(MOZ_X11)
|
||||
class nsGLPbufferGLX :
|
||||
public nsGLPbuffer
|
||||
{
|
||||
public:
|
||||
nsGLPbufferGLX();
|
||||
virtual ~nsGLPbufferGLX();
|
||||
|
||||
virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
|
||||
virtual PRBool Resize(PRInt32 width, PRInt32 height);
|
||||
virtual void Destroy();
|
||||
|
||||
virtual void MakeContextCurrent();
|
||||
virtual void SwapBuffers();
|
||||
|
||||
virtual gfxASurface* ThebesSurface();
|
||||
|
||||
protected:
|
||||
nsRefPtr<gfxImageSurface> mThebesSurface;
|
||||
|
||||
Display *mDisplay;
|
||||
GLXFBConfig mFBConfig;
|
||||
GLXPbuffer mPbuffer;
|
||||
GLXContext mPbufferContext;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
class nsGLPbufferWGL :
|
||||
public nsGLPbuffer
|
||||
{
|
||||
public:
|
||||
nsGLPbufferWGL();
|
||||
virtual ~nsGLPbufferWGL();
|
||||
|
||||
virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
|
||||
virtual PRBool Resize(PRInt32 width, PRInt32 height);
|
||||
virtual void Destroy();
|
||||
|
||||
virtual void MakeContextCurrent();
|
||||
virtual void SwapBuffers();
|
||||
|
||||
virtual gfxASurface* ThebesSurface();
|
||||
|
||||
protected:
|
||||
// this is the crap that we need to get the gl entry points
|
||||
HWND mGlewWindow;
|
||||
HDC mGlewDC;
|
||||
HANDLE mGlewWglContext;
|
||||
|
||||
// and this is the actual stuff that we need to render
|
||||
HANDLE mPbuffer;
|
||||
HDC mPbufferDC;
|
||||
HANDLE mPbufferContext;
|
||||
|
||||
nsRefPtr<gfxImageSurface> mThebesSurface;
|
||||
nsRefPtr<gfxWindowsSurface> mWindowsSurface;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* NSGLPBUFFER_H_ */
|
|
@ -0,0 +1,249 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
#include "nsICanvasRenderingContextGL.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
#include "nsCanvasRenderingContextGL.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
static PRUint32 gActiveBuffers = 0;
|
||||
|
||||
nsGLPbufferCGL::nsGLPbufferCGL()
|
||||
: mContext(nsnull), mPbuffer(nsnull), fFlush(nsnull)
|
||||
{
|
||||
gActiveBuffers++;
|
||||
fprintf (stderr, "nsGLPbuffer: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferCGL::Init(nsCanvasRenderingContextGLPrivate *priv)
|
||||
{
|
||||
mPriv = priv;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRInt32 prefAntialiasing;
|
||||
rv = prefBranch->GetIntPref("antialiasing", &prefAntialiasing);
|
||||
if (NS_FAILED(rv))
|
||||
prefAntialiasing = 0;
|
||||
|
||||
CGLPixelFormatAttribute attrib[] = {
|
||||
kCGLPFAAccelerated,
|
||||
kCGLPFAMinimumPolicy,
|
||||
kCGLPFAPBuffer,
|
||||
kCGLPFAColorSize, (CGLPixelFormatAttribute) 24,
|
||||
kCGLPFAAlphaSize, (CGLPixelFormatAttribute) 8,
|
||||
kCGLPFADepthSize, (CGLPixelFormatAttribute) 8,
|
||||
(CGLPixelFormatAttribute) 0
|
||||
};
|
||||
|
||||
#if 0
|
||||
if (false && prefAntialiasing > 0) {
|
||||
attrib[12] = AGL_SAMPLE_BUFFERS_ARB;
|
||||
attrib[13] = 1;
|
||||
|
||||
attrib[14] = AGL_SAMPLES_ARB;
|
||||
attrib[15] = 1 << prefAntialiasing;
|
||||
}
|
||||
#endif
|
||||
|
||||
CGLError err;
|
||||
|
||||
GLint npix;
|
||||
err = CGLChoosePixelFormat(attrib, &mPixelFormat, &npix);
|
||||
if (err) {
|
||||
fprintf (stderr, "CGLChoosePixelFormat failed: %d\n", err);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// we need a context for glewInit
|
||||
Resize(2, 2);
|
||||
MakeContextCurrent();
|
||||
|
||||
if (!mGLWrap.OpenLibrary("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib")) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Failed to open LibGL.dylib (tried system OpenGL.framework)"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!mGLWrap.Init(GLES20Wrap::TRY_NATIVE_GL)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
fFlush = (PFNGLFLUSHPROC) mGLWrap.LookupSymbol("glFlush", true);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferCGL::Resize(PRInt32 width, PRInt32 height)
|
||||
{
|
||||
if (mWidth == width &&
|
||||
mHeight == height)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
mThebesSurface = nsnull;
|
||||
mQuartzSurface = nsnull;
|
||||
|
||||
CGLError err;
|
||||
|
||||
err = CGLCreateContext(mPixelFormat, NULL, &mContext);
|
||||
if (err) {
|
||||
fprintf (stderr, "CGLCreateContext failed: %d\n", err);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
err = CGLCreatePBuffer(width, height, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA, 0, &mPbuffer);
|
||||
if (err) {
|
||||
fprintf (stderr, "CGLCreatePBuffer failed: %d\n", err);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
GLint screen;
|
||||
err = CGLGetVirtualScreen(mContext, &screen);
|
||||
if (err) {
|
||||
fprintf (stderr, "CGLGetVirtualScreen failed: %d\n", err);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
err = CGLSetPBuffer(mContext, mPbuffer, 0, 0, screen);
|
||||
if (err) {
|
||||
fprintf (stderr, "CGLSetPBuffer failed: %d\n", err);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferCGL::Destroy()
|
||||
{
|
||||
sCurrentContextToken = nsnull;
|
||||
mThebesSurface = nsnull;
|
||||
|
||||
if (mContext) {
|
||||
CGLDestroyContext(mContext);
|
||||
mContext = nsnull;
|
||||
}
|
||||
if (mPbuffer) {
|
||||
CGLDestroyPBuffer(mPbuffer);
|
||||
mPbuffer = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsGLPbufferCGL::~nsGLPbufferCGL()
|
||||
{
|
||||
Destroy();
|
||||
|
||||
if (mPixelFormat) {
|
||||
CGLDestroyPixelFormat(mPixelFormat);
|
||||
mPixelFormat = nsnull;
|
||||
}
|
||||
|
||||
gActiveBuffers--;
|
||||
fprintf (stderr, "nsGLPbuffer: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferCGL::MakeContextCurrent()
|
||||
{
|
||||
CGLError err = CGLSetCurrentContext (mContext);
|
||||
if (err) {
|
||||
fprintf (stderr, "CGLSetCurrentContext failed: %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferCGL::SwapBuffers()
|
||||
{
|
||||
MakeContextCurrent();
|
||||
|
||||
// oddly, CGLFlushDrawable() doesn't seem to work, even though it should be calling
|
||||
// glFlush first.
|
||||
if (fFlush)
|
||||
fFlush();
|
||||
|
||||
mImageNeedsUpdate = PR_TRUE;
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
nsGLPbufferCGL::ThebesSurface()
|
||||
{
|
||||
if (!mThebesSurface) {
|
||||
mThebesSurface = CanvasGLThebes::CreateImageSurface(gfxIntSize(mWidth, mHeight), gfxASurface::ImageFormatARGB32);
|
||||
if (mThebesSurface->CairoStatus() != 0) {
|
||||
fprintf (stderr, "image surface failed\n");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
mQuartzSurface = new gfxQuartzImageSurface(mThebesSurface);
|
||||
|
||||
mImageNeedsUpdate = PR_TRUE;
|
||||
}
|
||||
|
||||
if (mImageNeedsUpdate) {
|
||||
MakeContextCurrent();
|
||||
mGLWrap.fReadPixels (0, 0, mWidth, mHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, mThebesSurface->Data());
|
||||
|
||||
mQuartzSurface->Flush();
|
||||
|
||||
mImageNeedsUpdate = PR_FALSE;
|
||||
}
|
||||
|
||||
return mQuartzSurface;
|
||||
}
|
|
@ -0,0 +1,338 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
// this must be first, else windows.h breaks us
|
||||
#include "nsICanvasRenderingContextGL.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
#include "nsCanvasRenderingContextGL.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11)
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
static PRUint32 gActiveBuffers = 0;
|
||||
|
||||
class GLXWrap
|
||||
: public LibrarySymbolLoader
|
||||
{
|
||||
public:
|
||||
GLXWrap() : fCreateNewContext(0) { }
|
||||
|
||||
bool Init();
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// the wrapped functions
|
||||
//
|
||||
public:
|
||||
typedef PRFuncPtr (* PFNGLXGETPROCADDRESS) (const GLubyte *procName);
|
||||
PFNGLXGETPROCADDRESS fGetProcAddress;
|
||||
typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
|
||||
PFNGLXCREATENEWCONTEXTPROC fCreateNewContext;
|
||||
typedef XVisualInfo* (* PFNGLXCHOOSEVISUALPROC) (Display *dpy, int scrnum, int *attrib);
|
||||
PFNGLXCHOOSEVISUALPROC fChooseVisual;
|
||||
typedef GLXContext (* PFNGLXCREATECONTEXTPROC) (Display *dpy, XVisualInfo *visinfo, GLXContext share_list, Bool direct);
|
||||
PFNGLXCREATECONTEXTPROC fCreateContext;
|
||||
typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
|
||||
PFNGLXCREATEPBUFFERPROC fCreatePbuffer;
|
||||
typedef void (* PFNGLXDESTROYCONTEXTPROC) (Display *dpy, GLXContext ctx);
|
||||
PFNGLXDESTROYCONTEXTPROC fDestroyContext;
|
||||
typedef void (* PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
|
||||
PFNGLXDESTROYPBUFFERPROC fDestroyPbuffer;
|
||||
typedef GLXFBConfig* (* PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
|
||||
PFNGLXCHOOSEFBCONFIGPROC fChooseFBConfig;
|
||||
typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
|
||||
PFNGLXMAKECONTEXTCURRENTPROC fMakeContextCurrent;
|
||||
typedef GLXContext (* PFNGLXGETCURRENTCONTEXTPROC) ( void );
|
||||
PFNGLXGETCURRENTCONTEXTPROC fGetCurrentContext;
|
||||
typedef const char* (* PFNGLXQUERYEXTENSIONSSTRING) (Display *dpy, int screen);
|
||||
PFNGLXQUERYEXTENSIONSSTRING fQueryExtensionsString;
|
||||
typedef const char* (* PFNGLXQUERYSERVERSTRING) (Display *dpy, int screen, int name);
|
||||
PFNGLXQUERYSERVERSTRING fQueryServerString;
|
||||
};
|
||||
|
||||
bool
|
||||
GLXWrap::Init()
|
||||
{
|
||||
if (fCreateNewContext)
|
||||
return true;
|
||||
|
||||
SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &fGetProcAddress, { "glXGetProcAddress", "glXGetProcAddressARB", NULL } },
|
||||
{ (PRFuncPtr*) &fCreateNewContext, { "glXCreateNewContext", NULL } },
|
||||
{ (PRFuncPtr*) &fCreateContext, { "glXCreateContext", NULL } },
|
||||
{ (PRFuncPtr*) &fChooseVisual, { "glXChooseVisual", NULL } },
|
||||
{ (PRFuncPtr*) &fCreatePbuffer, { "glXCreatePbuffer", NULL } },
|
||||
{ (PRFuncPtr*) &fDestroyContext, { "glXDestroyContext", NULL } },
|
||||
{ (PRFuncPtr*) &fDestroyPbuffer, { "glXDestroyPbuffer", NULL } },
|
||||
{ (PRFuncPtr*) &fChooseFBConfig, { "glXChooseFBConfig", NULL } },
|
||||
{ (PRFuncPtr*) &fMakeContextCurrent, { "glXMakeContextCurrent", NULL } },
|
||||
{ (PRFuncPtr*) &fGetCurrentContext, { "glXGetCurrentContext", NULL } },
|
||||
{ (PRFuncPtr*) &fQueryExtensionsString, { "glXQueryExtensionsString", NULL } },
|
||||
{ (PRFuncPtr*) &fQueryServerString, { "glXQueryServerString", NULL } },
|
||||
{ NULL, { NULL } }
|
||||
};
|
||||
|
||||
return LoadSymbols(&symbols[0]);
|
||||
}
|
||||
|
||||
static GLXWrap gGLXWrap;
|
||||
|
||||
nsGLPbufferGLX::nsGLPbufferGLX()
|
||||
: mDisplay(nsnull), mFBConfig(0), mPbuffer(0), mPbufferContext(0)
|
||||
{
|
||||
gActiveBuffers++;
|
||||
fprintf (stderr, "nsGLPbufferGLX: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferGLX::Init(nsCanvasRenderingContextGLPrivate *priv)
|
||||
{
|
||||
nsresult rv;
|
||||
const char *s;
|
||||
|
||||
if (!gGLXWrap.OpenLibrary("libGL.so.1")) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't find libGL.so.1"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!gGLXWrap.Init()) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: gGLXWrap.Init() failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11)
|
||||
mDisplay = gdk_x11_get_default_xdisplay();
|
||||
#else
|
||||
mDisplay = XOpenDisplay(NULL);
|
||||
#endif
|
||||
if (!mDisplay) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: XOpenDisplay failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Make sure that everyone agrees that pbuffers are supported
|
||||
s = gGLXWrap.fQueryExtensionsString(mDisplay, DefaultScreen(mDisplay));
|
||||
if (strstr(s, "GLX_SGIX_pbuffer") == NULL) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLX_SGIX_pbuffer not supported"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
s = gGLXWrap.fQueryServerString(mDisplay, DefaultScreen(mDisplay), GLX_EXTENSIONS);
|
||||
if (strstr(s, "GLX_SGIX_pbuffer") == NULL) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLX_SGIX_pbuffer not supported by server"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mPriv = priv;
|
||||
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRInt32 prefAntialiasing;
|
||||
rv = prefBranch->GetIntPref("antialiasing", &prefAntialiasing);
|
||||
if (NS_FAILED(rv))
|
||||
prefAntialiasing = 0;
|
||||
|
||||
int attrib[] = { GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_ALPHA_SIZE, 1,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
GLX_SAMPLE_BUFFERS, 1,
|
||||
GLX_SAMPLES, 1 << prefAntialiasing,
|
||||
None };
|
||||
if (prefAntialiasing <= 0)
|
||||
attrib[16] = 0;
|
||||
int num;
|
||||
GLXFBConfig *configs = gGLXWrap.fChooseFBConfig(mDisplay, DefaultScreen(mDisplay),
|
||||
attrib, &num);
|
||||
|
||||
fprintf(stderr, "CANVAS3D FBCONFIG: %d %p\n", num, (void*) configs);
|
||||
if (!configs) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: No GLXFBConfig found"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// choose first matching config;
|
||||
mFBConfig = *configs;
|
||||
|
||||
XFree(configs);
|
||||
|
||||
mPbufferContext = gGLXWrap.fCreateNewContext(mDisplay, mFBConfig, GLX_RGBA_TYPE,
|
||||
nsnull, True);
|
||||
|
||||
PRInt64 t1 = PR_Now();
|
||||
|
||||
Resize(2, 2);
|
||||
MakeContextCurrent();
|
||||
|
||||
PRInt64 t2 = PR_Now();
|
||||
|
||||
fprintf (stderr, "nsGLPbufferGLX::Init!\n");
|
||||
|
||||
if (!mGLWrap.OpenLibrary("libGL.so.1")) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed, couldn't find libGL.so.1"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) gGLXWrap.fGetProcAddress);
|
||||
|
||||
if (!mGLWrap.Init(GLES20Wrap::TRY_NATIVE_GL)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt64 t3 = PR_Now();
|
||||
|
||||
fprintf (stderr, "nsGLPbufferGLX:: Initialization took t2-t1: %f t3-t2: %f\n",
|
||||
((double)(t2-t1))/1000.0, ((double)(t3-t2))/1000.0);
|
||||
fflush (stderr);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferGLX::Resize(PRInt32 width, PRInt32 height)
|
||||
{
|
||||
if (mWidth == width &&
|
||||
mHeight == height)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
mThebesSurface = CanvasGLThebes::CreateImageSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32);
|
||||
if (mThebesSurface->CairoStatus() != 0) {
|
||||
fprintf (stderr, "image surface failed\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// clear the surface
|
||||
memset (mThebesSurface->Data(),
|
||||
0,
|
||||
height * mThebesSurface->Stride());
|
||||
|
||||
int attrib[] = { GLX_PBUFFER_WIDTH, width,
|
||||
GLX_PBUFFER_HEIGHT, height,
|
||||
None };
|
||||
|
||||
mPbuffer = gGLXWrap.fCreatePbuffer(mDisplay, mFBConfig, attrib);
|
||||
gGLXWrap.fMakeContextCurrent(mDisplay, mPbuffer, mPbuffer, mPbufferContext);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
fprintf (stderr, "Resize: %d %d\n", width, height);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferGLX::Destroy()
|
||||
{
|
||||
sCurrentContextToken = nsnull;
|
||||
mThebesSurface = nsnull;
|
||||
|
||||
if (mPbuffer) {
|
||||
gGLXWrap.fDestroyPbuffer(mDisplay, mPbuffer);
|
||||
mPbuffer = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsGLPbufferGLX::~nsGLPbufferGLX()
|
||||
{
|
||||
MakeContextCurrent();
|
||||
#ifndef GL_FRAMEBUFFER
|
||||
#define GL_FRAMEBUFFER 0x8D40
|
||||
#endif
|
||||
// workaround for segfault on glXDestroyContext
|
||||
mGLWrap.fBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
Destroy();
|
||||
|
||||
if (mPbuffer)
|
||||
gGLXWrap.fDestroyPbuffer(mDisplay, mPbuffer);
|
||||
if (mPbufferContext)
|
||||
gGLXWrap.fDestroyContext(mDisplay, mPbufferContext);
|
||||
#if !(defined(MOZ_WIDGET_GTK2) && defined(MOZ_X11))
|
||||
if (mDisplay)
|
||||
XCloseDisplay(mDisplay);
|
||||
#endif
|
||||
|
||||
gActiveBuffers--;
|
||||
fprintf (stderr, "nsGLPbufferGLX: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferGLX::MakeContextCurrent()
|
||||
{
|
||||
if (gGLXWrap.fGetCurrentContext() != mPbufferContext)
|
||||
gGLXWrap.fMakeContextCurrent(mDisplay, mPbuffer, mPbuffer, mPbufferContext);
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferGLX::SwapBuffers()
|
||||
{
|
||||
MakeContextCurrent();
|
||||
mGLWrap.fReadPixels (0, 0, mWidth, mHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, mThebesSurface->Data());
|
||||
unsigned int len = mWidth*mHeight*4;
|
||||
unsigned char *src = mThebesSurface->Data();
|
||||
// Premultiply the image
|
||||
// XXX don't do this if we're known opaque
|
||||
Premultiply(src, len);
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
nsGLPbufferGLX::ThebesSurface()
|
||||
{
|
||||
return mThebesSurface;
|
||||
}
|
|
@ -0,0 +1,249 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
// this must be first, else windows.h breaks us
|
||||
#include "nsICanvasRenderingContextGL.h"
|
||||
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
#include "nsCanvasRenderingContextGL.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "glwrap.h"
|
||||
|
||||
#if 0
|
||||
#include <GL/osmesa.h>
|
||||
#else
|
||||
#define OSMESA_RGBA GL_RGBA
|
||||
#define OSMESA_BGRA 0x1
|
||||
#define OSMESA_ARGB 0x2
|
||||
#define OSMESA_Y_UP 0x11
|
||||
#endif
|
||||
|
||||
static OSMesaWrap gMesaWrap;
|
||||
|
||||
static PRUint32 gActiveBuffers = 0;
|
||||
|
||||
nsGLPbufferOSMESA::nsGLPbufferOSMESA()
|
||||
: mMesaContext(nsnull)
|
||||
{
|
||||
gActiveBuffers++;
|
||||
fprintf (stderr, "nsGLPbufferOSMESA: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferOSMESA::Init(nsCanvasRenderingContextGLPrivate *priv)
|
||||
{
|
||||
mPriv = priv;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
nsCString osmesalib;
|
||||
|
||||
rv = prefBranch->GetCharPref("osmesalib", getter_Copies(osmesalib));
|
||||
if (NS_FAILED(rv)) {
|
||||
osmesalib.Truncate();
|
||||
|
||||
// try our default; build it from the profile dir
|
||||
nsCOMPtr<nsIFile> libfile;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(libfile));
|
||||
if (NS_FAILED(rv)) {
|
||||
fprintf (stderr, "NS_GetSpecialDirectory failed?\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX this makes assumptions about the ID of this extension
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("extensions"));
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("canvas3d@mozilla.com"));
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("platform"));
|
||||
|
||||
#if defined(XP_WIN)
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("WINNT"));
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("osmesa32.dll"));
|
||||
#elif defined(XP_MACOSX)
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("Darwin"));
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("libOSMesa.7.dylib"));
|
||||
#elif defined(XP_UNIX)
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("Linux"));
|
||||
rv |= libfile->Append(NS_LITERAL_STRING("libOSMesa.so.7"));
|
||||
#else
|
||||
#warning No default osmesa library path available
|
||||
LogMessage(NS_LITERAL_STRING("Canvas 3D: No default OSMesa lib path available -- please set the extensions.canvas3d.osmesalib pref to the full path to the OSMesa shared library"));
|
||||
rv = NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool exists = PR_FALSE;
|
||||
rv = libfile->Exists(&exists);
|
||||
if (NS_FAILED(rv) || !exists) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't find OSMesa lib -- either default or extension.canvas3d.osmesalib path is incorrect"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// I'm told by the comments in nsIFile that I'm not supposed to do this. Noted.
|
||||
rv = libfile->GetNativeTarget(osmesalib);
|
||||
if (NS_FAILED(rv)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't find OSMesa lib"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gMesaWrap.OpenLibrary(osmesalib.get())) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't open OSMesa lib -- either default or extension.canvas3d.osmesalib path is incorrect, or not a valid shared library"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!gMesaWrap.Init())
|
||||
return PR_FALSE;
|
||||
|
||||
PRInt32 prefAntialiasing;
|
||||
rv = prefBranch->GetIntPref("antialiasing", &prefAntialiasing);
|
||||
if (NS_FAILED(rv))
|
||||
prefAntialiasing = 0;
|
||||
|
||||
Resize (2, 2);
|
||||
|
||||
if (!mGLWrap.OpenLibrary(osmesalib.get())) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't open OSMesa lib [1]"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) gMesaWrap.fGetProcAddress);
|
||||
|
||||
if (!mGLWrap.Init(GLES20Wrap::TRY_SOFTWARE_GL)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferOSMESA::Resize(PRInt32 width, PRInt32 height)
|
||||
{
|
||||
if (mWidth == width &&
|
||||
mHeight == height)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
mThebesSurface = CanvasGLThebes::CreateImageSurface(gfxIntSize(width, height),
|
||||
gfxASurface::ImageFormatARGB32);
|
||||
if (mThebesSurface->CairoStatus() != 0) {
|
||||
fprintf (stderr, "image surface failed\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mMesaContext = gMesaWrap.fCreateContextExt (OSMESA_BGRA, 16, 0, 0, NULL);
|
||||
if (!mMesaContext) {
|
||||
fprintf (stderr, "OSMesaCreateContextExt failed!\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
fprintf (stderr, "Surface: %p\n", mThebesSurface->Data());
|
||||
|
||||
if (!gMesaWrap.fMakeCurrent (mMesaContext, mThebesSurface->Data(), GL_UNSIGNED_BYTE, width, height))
|
||||
{
|
||||
fprintf (stderr, "OSMesaMakeCurrent failed!\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
gMesaWrap.fPixelStore (OSMESA_Y_UP, 1);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
fprintf (stderr, "Resize: %d %d\n", width, height);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferOSMESA::Destroy()
|
||||
{
|
||||
if (mMesaContext) {
|
||||
gMesaWrap.fDestroyContext (mMesaContext);
|
||||
mMesaContext = 0;
|
||||
}
|
||||
|
||||
sCurrentContextToken = nsnull;
|
||||
mThebesSurface = nsnull;
|
||||
}
|
||||
|
||||
nsGLPbufferOSMESA::~nsGLPbufferOSMESA()
|
||||
{
|
||||
Destroy();
|
||||
|
||||
gActiveBuffers--;
|
||||
fprintf (stderr, "nsGLPbufferOSMESA: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferOSMESA::MakeContextCurrent()
|
||||
{
|
||||
if (gMesaWrap.fGetCurrentContext() == mMesaContext)
|
||||
return;
|
||||
|
||||
gMesaWrap.fMakeCurrent (mMesaContext, mThebesSurface->Data(), GL_UNSIGNED_BYTE, mWidth, mHeight);
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferOSMESA::SwapBuffers()
|
||||
{
|
||||
// Nothing; we're already rendering to an image
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
nsGLPbufferOSMESA::ThebesSurface()
|
||||
{
|
||||
return mThebesSurface;
|
||||
}
|
|
@ -0,0 +1,423 @@
|
|||
/* -*- 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) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
// this must be first, else windows.h breaks us
|
||||
#include "nsICanvasRenderingContextGL.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
#include "nsCanvasRenderingContextGL.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
static PRUint32 gActiveBuffers = 0;
|
||||
|
||||
class WGLWrap
|
||||
: public LibrarySymbolLoader
|
||||
{
|
||||
public:
|
||||
WGLWrap() : fCreatePbuffer(0) { }
|
||||
|
||||
bool Init();
|
||||
|
||||
public:
|
||||
typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);
|
||||
PFNWGLCREATEPBUFFERPROC fCreatePbuffer;
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer);
|
||||
PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer;
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer);
|
||||
PFNWGLGETPBUFFERDCPROC fGetPbufferDC;
|
||||
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);
|
||||
PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
|
||||
};
|
||||
|
||||
bool
|
||||
WGLWrap::Init()
|
||||
{
|
||||
if (fCreatePbuffer)
|
||||
return true;
|
||||
|
||||
SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &fCreatePbuffer, { "wglCreatePbufferARB", "wglCreatePbufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fDestroyPbuffer, { "wglDestroyPbufferARB", "wglDestroyPbufferEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGetPbufferDC, { "wglGetPbufferDCARB", "wglGetPbufferDCEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fChoosePixelFormat, { "wglChoosePixelFormatARB", "wglChoosePixelFormatEXT", NULL } },
|
||||
{ (PRFuncPtr*) &fGetPixelFormatAttribiv, { "wglGetPixelFormatAttribivARB", "wglGetPixelFormatAttribivEXT", NULL } },
|
||||
{ NULL, { NULL } }
|
||||
};
|
||||
|
||||
return LoadSymbols(&symbols[0], true);
|
||||
}
|
||||
|
||||
static WGLWrap gWGLWrap;
|
||||
|
||||
nsGLPbufferWGL::nsGLPbufferWGL()
|
||||
: mGlewWindow(nsnull), mGlewDC(nsnull), mGlewWglContext(nsnull),
|
||||
mPbuffer(nsnull), mPbufferDC(nsnull), mPbufferContext(nsnull)
|
||||
{
|
||||
gActiveBuffers++;
|
||||
fprintf (stderr, "nsGLPbufferWGL: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferWGL::Init(nsCanvasRenderingContextGLPrivate *priv)
|
||||
{
|
||||
// XXX lookup SYSTEM32 path!
|
||||
char *opengl32 = "C:\\WINDOWS\\SYSTEM32\\OPENGL32.DLL";
|
||||
|
||||
if (!gWGLWrap.OpenLibrary(opengl32))
|
||||
return PR_FALSE;
|
||||
|
||||
gWGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) wglGetProcAddress);
|
||||
|
||||
mPriv = priv;
|
||||
|
||||
WNDCLASS wc;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
if (!GetClassInfo(GetModuleHandle(NULL), "GLEW", &wc)) {
|
||||
ZeroMemory(&wc, sizeof(WNDCLASS));
|
||||
wc.hInstance = GetModuleHandle(NULL);
|
||||
wc.lpfnWndProc = DefWindowProc;
|
||||
wc.lpszClassName = "GLEW";
|
||||
|
||||
if (!RegisterClass(&wc)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: RegisterClass failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// create window
|
||||
mGlewWindow = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||
if (!mGlewWindow) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: CreateWindow failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// get the device context
|
||||
mGlewDC = GetDC(mGlewWindow);
|
||||
if (!mGlewDC) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GetDC failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// find default pixel format
|
||||
ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
|
||||
int pixelformat = ChoosePixelFormat(mGlewDC, &pfd);
|
||||
|
||||
// set the pixel format for the dc
|
||||
if (!SetPixelFormat(mGlewDC, pixelformat, &pfd)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: SetPixelFormat failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// create rendering context
|
||||
mGlewWglContext = wglCreateContext(mGlewDC);
|
||||
if (!mGlewWglContext) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: wglCreateContext failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!wglMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: wglMakeCurrent failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// grab all the wgl extension pieces that we couldn't grab before
|
||||
// we had a context
|
||||
if (!gWGLWrap.Init())
|
||||
return PR_FALSE;
|
||||
|
||||
// XXX look up system32 dir
|
||||
if (!mGLWrap.OpenLibrary(opengl32)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Failed to open opengl32.dll (only looked in c:\\windows\\system32, fixme)"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) wglGetProcAddress);
|
||||
|
||||
if (!mGLWrap.Init(GLES20Wrap::TRY_NATIVE_GL)) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGLPbufferWGL::Resize(PRInt32 width, PRInt32 height)
|
||||
{
|
||||
if (mWidth == width &&
|
||||
mHeight == height)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRInt32 prefAntialiasing;
|
||||
rv = prefBranch->GetIntPref("antialiasing", &prefAntialiasing);
|
||||
if (NS_FAILED(rv))
|
||||
prefAntialiasing = 0;
|
||||
|
||||
mThebesSurface = CanvasGLThebes::CreateImageSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32);
|
||||
if (mThebesSurface->CairoStatus() != 0) {
|
||||
fprintf (stderr, "image surface failed\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// clear the surface
|
||||
memset (mThebesSurface->Data(),
|
||||
0,
|
||||
height * mThebesSurface->Stride());
|
||||
|
||||
if (!wglMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {
|
||||
fprintf (stderr, "Error: %d\n", GetLastError());
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: wglMakeCurrent failed"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool ignoreAA = PR_FALSE;
|
||||
int attribs[] = {
|
||||
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
|
||||
WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE,
|
||||
WGL_DOUBLE_BUFFER_ARB, GL_FALSE,
|
||||
|
||||
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
|
||||
|
||||
WGL_COLOR_BITS_ARB, 32,
|
||||
WGL_RED_BITS_ARB, 8,
|
||||
WGL_GREEN_BITS_ARB, 8,
|
||||
WGL_BLUE_BITS_ARB, 8,
|
||||
WGL_ALPHA_BITS_ARB, 8,
|
||||
|
||||
0, 0,
|
||||
0, 0,
|
||||
0
|
||||
};
|
||||
|
||||
float fattribs[] = { 0.0f };
|
||||
|
||||
// ATI's OpenGL impl seems to have a problem with calling
|
||||
// wglChoosePixelFormatARB with NULL/0 to obtain the number of
|
||||
// matching formats; so just allocate room for a lot.
|
||||
#define MAX_NUM_FORMATS 256
|
||||
UINT numFormats = MAX_NUM_FORMATS;
|
||||
nsAutoArrayPtr<int> formats = new int[numFormats];
|
||||
|
||||
//fprintf (stderr, "EXT: %p ARB: %p rest: %s\n", wglewGetContext()->__wglewChoosePixelFormatEXT, wglewGetContext()->__wglewChoosePixelFormatARB, wglGetExtensionsStringARB(mGlewDC));
|
||||
|
||||
TRY_FIND_AGAIN:
|
||||
if (ignoreAA) {
|
||||
attribs[18] = 0;
|
||||
} else if (prefAntialiasing > 0) {
|
||||
attribs[18] = WGL_SAMPLE_BUFFERS_ARB;
|
||||
attribs[19] = 1;
|
||||
attribs[20] = WGL_SAMPLES_ARB;
|
||||
attribs[21] = 1 << prefAntialiasing;
|
||||
}
|
||||
|
||||
if (!gWGLWrap.fChoosePixelFormat(mGlewDC,
|
||||
attribs,
|
||||
NULL,
|
||||
numFormats,
|
||||
formats,
|
||||
&numFormats) ||
|
||||
numFormats == 0)
|
||||
{
|
||||
if (!ignoreAA) {
|
||||
ignoreAA = PR_TRUE;
|
||||
goto TRY_FIND_AGAIN;
|
||||
}
|
||||
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: wglChoosePixelFormat failed (or couldn't find any matching formats)."));
|
||||
ReleaseDC(NULL, mGlewDC);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
int chosenFormat = -1;
|
||||
int question,answer;
|
||||
|
||||
for (int priority = 6; priority > 0; priority--) {
|
||||
|
||||
//fprintf (stderr, "---- priority: %d\n", priority);
|
||||
|
||||
for (UINT i = 0; i < numFormats; i++) {
|
||||
int fmt = formats[i];
|
||||
#define CHECK_ATTRIB(q, test) \
|
||||
question = (q); \
|
||||
if (!gWGLWrap.fGetPixelFormatAttribiv(mGlewDC, fmt, 0, 1, &question, &answer)) { \
|
||||
/*fprintf (stderr, "check for %d failed\n", q);*/ \
|
||||
continue; \
|
||||
} \
|
||||
/*fprintf (stderr, #q " -> %d\n", answer);*/ \
|
||||
if (test) { \
|
||||
continue; \
|
||||
}
|
||||
|
||||
//fprintf (stderr, "Format %d:\n", fmt);
|
||||
switch (priority) {
|
||||
case 6:
|
||||
CHECK_ATTRIB(WGL_ACCUM_BITS_ARB, answer != 0)
|
||||
case 5:
|
||||
CHECK_ATTRIB(WGL_STENCIL_BITS_ARB, answer != 0)
|
||||
// XXX we only pick 2xAA here, should let user choose
|
||||
case 4:
|
||||
CHECK_ATTRIB(WGL_SAMPLE_BUFFERS_ARB, answer != (prefAntialiasing != 0))
|
||||
case 3:
|
||||
CHECK_ATTRIB(WGL_SAMPLES_ARB, answer != (prefAntialiasing ? (1 << prefAntialiasing) : 0))
|
||||
case 2:
|
||||
CHECK_ATTRIB(WGL_DEPTH_BITS_ARB, answer < 8)
|
||||
case 1:
|
||||
CHECK_ATTRIB(WGL_COLOR_BITS_ARB, answer != 32)
|
||||
default:
|
||||
chosenFormat = fmt;
|
||||
}
|
||||
|
||||
#undef CHECK_ATTRIB
|
||||
}
|
||||
|
||||
if (chosenFormat != -1)
|
||||
break;
|
||||
}
|
||||
|
||||
if (chosenFormat == -1) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't find a suitable pixel format!"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// ok, we now have a pixel format
|
||||
fprintf (stderr, "***** Chose pixel format: %d\n", chosenFormat);
|
||||
|
||||
int pbattribs = 0;
|
||||
mPbuffer = gWGLWrap.fCreatePbuffer(mGlewDC, chosenFormat, width, height, &pbattribs);
|
||||
if (!mPbuffer) {
|
||||
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Failed to create pbuffer"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mPbufferDC = gWGLWrap.fGetPbufferDC(mPbuffer);
|
||||
mPbufferContext = wglCreateContext(mPbufferDC);
|
||||
|
||||
mWindowsSurface = new gfxWindowsSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32);
|
||||
if (mWindowsSurface && mWindowsSurface->CairoStatus() == 0)
|
||||
mThebesSurface = mWindowsSurface->GetImageSurface();
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
fprintf (stderr, "Resize: %d %d\n", width, height);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferWGL::Destroy()
|
||||
{
|
||||
sCurrentContextToken = nsnull;
|
||||
mThebesSurface = nsnull;
|
||||
|
||||
if (mPbuffer) {
|
||||
wglDeleteContext((HGLRC) mPbufferContext);
|
||||
gWGLWrap.fDestroyPbuffer(mPbuffer);
|
||||
mPbuffer = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsGLPbufferWGL::~nsGLPbufferWGL()
|
||||
{
|
||||
Destroy();
|
||||
|
||||
if (mGlewWglContext) {
|
||||
wglDeleteContext((HGLRC) mGlewWglContext);
|
||||
mGlewWglContext = nsnull;
|
||||
}
|
||||
|
||||
if (mGlewWindow) {
|
||||
DestroyWindow(mGlewWindow);
|
||||
mGlewWindow = nsnull;
|
||||
}
|
||||
|
||||
gActiveBuffers--;
|
||||
fprintf (stderr, "nsGLPbufferWGL: gActiveBuffers: %d\n", gActiveBuffers);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferWGL::MakeContextCurrent()
|
||||
{
|
||||
if (sCurrentContextToken == mPbufferContext)
|
||||
return;
|
||||
|
||||
wglMakeCurrent (mPbufferDC, (HGLRC) mPbufferContext);
|
||||
sCurrentContextToken = mPbufferContext;
|
||||
}
|
||||
|
||||
void
|
||||
nsGLPbufferWGL::SwapBuffers()
|
||||
{
|
||||
MakeContextCurrent();
|
||||
mGLWrap.fReadPixels (0, 0, mWidth, mHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, mThebesSurface->Data());
|
||||
|
||||
// premultiply the image
|
||||
int len = mWidth*mHeight*4;
|
||||
unsigned char *src = mThebesSurface->Data();
|
||||
Premultiply(src, len);
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
nsGLPbufferWGL::ThebesSurface()
|
||||
{
|
||||
return mThebesSurface;
|
||||
}
|
|
@ -431,6 +431,9 @@
|
|||
|
||||
#ifdef MOZ_ENABLE_CANVAS
|
||||
#include "nsIDOMCanvasRenderingContext2D.h"
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
#include "nsICanvasRenderingContextGLWeb20.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "nsIImageDocument.h"
|
||||
|
@ -1309,6 +1312,11 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
|
||||
NS_DEFINE_CLASSINFO_DATA(Worker, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
NS_DEFINE_CLASSINFO_DATA(CanvasRenderingContextGLWeb20, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
};
|
||||
|
||||
// Objects that shuld be constructable through |new Name();|
|
||||
|
@ -3592,6 +3600,13 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
DOM_CLASSINFO_MAP_BEGIN(CanvasRenderingContextGLWeb20, nsICanvasRenderingContextGLWeb20)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsICanvasRenderingContextGLWeb20)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsICanvasRenderingContextGL)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
{
|
||||
PRUint32 i = NS_ARRAY_LENGTH(sClassInfoData);
|
||||
|
|
|
@ -461,6 +461,10 @@ enum nsDOMClassInfoID {
|
|||
|
||||
eDOMClassInfo_Worker_id,
|
||||
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
eDOMClassInfo_CanvasRenderingContextGLWeb20_id,
|
||||
#endif
|
||||
|
||||
// This one better be the last one in this list
|
||||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
|
|
@ -46,8 +46,14 @@ MODULE = dom
|
|||
XPIDL_MODULE = dom_canvas
|
||||
GRE_MODULE = 1
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIDOMCanvasRenderingContext2D.idl \
|
||||
XPIDLSRCS = nsIDOMCanvasRenderingContext2D.idl
|
||||
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
XPIDLSRCS += \
|
||||
nsICanvasRenderingContextGL.idl \
|
||||
nsICanvasRenderingContextGLBuffer.idl \
|
||||
nsICanvasRenderingContextGLWeb20.idl \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,357 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 canvas 3D.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMHTMLCanvasElement;
|
||||
|
||||
[scriptable, uuid(0f3d8dae-7d43-490b-93e9-5ff908ac6ff5)]
|
||||
interface nsICanvasRenderingContextGL : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMHTMLCanvasElement canvas;
|
||||
|
||||
/**
|
||||
** GL constants
|
||||
**/
|
||||
const PRUint32 DEPTH_BUFFER_BIT = 0x00000100;
|
||||
const PRUint32 STENCIL_BUFFER_BIT = 0x00000400;
|
||||
const PRUint32 COLOR_BUFFER_BIT = 0x00004000;
|
||||
const PRUint32 POINTS = 0x0000;
|
||||
const PRUint32 LINES = 0x0001;
|
||||
const PRUint32 LINE_LOOP = 0x0002;
|
||||
const PRUint32 LINE_STRIP = 0x0003;
|
||||
const PRUint32 TRIANGLES = 0x0004;
|
||||
const PRUint32 TRIANGLE_STRIP = 0x0005;
|
||||
const PRUint32 TRIANGLE_FAN = 0x0006;
|
||||
const PRUint32 ZERO = 0;
|
||||
const PRUint32 ONE = 1;
|
||||
const PRUint32 SRC_COLOR = 0x0300;
|
||||
const PRUint32 ONE_MINUS_SRC_COLOR = 0x0301;
|
||||
const PRUint32 SRC_ALPHA = 0x0302;
|
||||
const PRUint32 ONE_MINUS_SRC_ALPHA = 0x0303;
|
||||
const PRUint32 DST_ALPHA = 0x0304;
|
||||
const PRUint32 ONE_MINUS_DST_ALPHA = 0x0305;
|
||||
const PRUint32 DST_COLOR = 0x0306;
|
||||
const PRUint32 ONE_MINUS_DST_COLOR = 0x0307;
|
||||
const PRUint32 SRC_ALPHA_SATURATE = 0x0308;
|
||||
const PRUint32 FUNC_ADD = 0x8006;
|
||||
const PRUint32 BLEND_EQUATION = 0x8009;
|
||||
const PRUint32 BLEND_EQUATION_RGB = 0x8009;
|
||||
const PRUint32 BLEND_EQUATION_ALPHA = 0x883D;
|
||||
const PRUint32 FUNC_SUBTRACT = 0x800A;
|
||||
const PRUint32 FUNC_REVERSE_SUBTRACT = 0x800B;
|
||||
const PRUint32 BLEND_DST_RGB = 0x80C8;
|
||||
const PRUint32 BLEND_SRC_RGB = 0x80C9;
|
||||
const PRUint32 BLEND_DST_ALPHA = 0x80CA;
|
||||
const PRUint32 BLEND_SRC_ALPHA = 0x80CB;
|
||||
const PRUint32 CONSTANT_COLOR = 0x8001;
|
||||
const PRUint32 ONE_MINUS_CONSTANT_COLOR = 0x8002;
|
||||
const PRUint32 CONSTANT_ALPHA = 0x8003;
|
||||
const PRUint32 ONE_MINUS_CONSTANT_ALPHA = 0x8004;
|
||||
const PRUint32 BLEND_COLOR = 0x8005;
|
||||
const PRUint32 ARRAY_BUFFER = 0x8892;
|
||||
const PRUint32 ELEMENT_ARRAY_BUFFER = 0x8893;
|
||||
const PRUint32 ARRAY_BUFFER_BINDING = 0x8894;
|
||||
const PRUint32 ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
|
||||
const PRUint32 STREAM_DRAW = 0x88E0;
|
||||
const PRUint32 STATIC_DRAW = 0x88E4;
|
||||
const PRUint32 DYNAMIC_DRAW = 0x88E8;
|
||||
const PRUint32 BUFFER_SIZE = 0x8764;
|
||||
const PRUint32 BUFFER_USAGE = 0x8765;
|
||||
const PRUint32 CURRENT_VERTEX_ATTRIB = 0x8626;
|
||||
const PRUint32 FRONT = 0x0404;
|
||||
const PRUint32 BACK = 0x0405;
|
||||
const PRUint32 FRONT_AND_BACK = 0x0408;
|
||||
const PRUint32 TEXTURE_2D = 0x0DE1;
|
||||
const PRUint32 CULL_FACE = 0x0B44;
|
||||
const PRUint32 BLEND = 0x0BE2;
|
||||
const PRUint32 DITHER = 0x0BD0;
|
||||
const PRUint32 STENCIL_TEST = 0x0B90;
|
||||
const PRUint32 DEPTH_TEST = 0x0B71;
|
||||
const PRUint32 SCISSOR_TEST = 0x0C11;
|
||||
const PRUint32 POLYGON_OFFSET_FILL = 0x8037;
|
||||
const PRUint32 SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
|
||||
const PRUint32 SAMPLE_COVERAGE = 0x80A0;
|
||||
const PRUint32 NO_ERROR = 0;
|
||||
const PRUint32 INVALID_ENUM = 0x0500;
|
||||
const PRUint32 INVALID_VALUE = 0x0501;
|
||||
const PRUint32 INVALID_OPERATION = 0x0502;
|
||||
const PRUint32 OUT_OF_MEMORY = 0x0505;
|
||||
const PRUint32 CW = 0x0900;
|
||||
const PRUint32 CCW = 0x0901;
|
||||
const PRUint32 LINE_WIDTH = 0x0B21;
|
||||
const PRUint32 ALIASED_POINT_SIZE_RANGE = 0x846D;
|
||||
const PRUint32 ALIASED_LINE_WIDTH_RANGE = 0x846E;
|
||||
const PRUint32 CULL_FACE_MODE = 0x0B45;
|
||||
const PRUint32 FRONT_FACE = 0x0B46;
|
||||
const PRUint32 DEPTH_RANGE = 0x0B70;
|
||||
const PRUint32 DEPTH_WRITEMASK = 0x0B72;
|
||||
const PRUint32 DEPTH_CLEAR_VALUE = 0x0B73;
|
||||
const PRUint32 DEPTH_FUNC = 0x0B74;
|
||||
const PRUint32 STENCIL_CLEAR_VALUE = 0x0B91;
|
||||
const PRUint32 STENCIL_FUNC = 0x0B92;
|
||||
const PRUint32 STENCIL_FAIL = 0x0B94;
|
||||
const PRUint32 STENCIL_PASS_DEPTH_FAIL = 0x0B95;
|
||||
const PRUint32 STENCIL_PASS_DEPTH_PASS = 0x0B96;
|
||||
const PRUint32 STENCIL_REF = 0x0B97;
|
||||
const PRUint32 STENCIL_VALUE_MASK = 0x0B93;
|
||||
const PRUint32 STENCIL_WRITEMASK = 0x0B98;
|
||||
const PRUint32 STENCIL_BACK_FUNC = 0x8800;
|
||||
const PRUint32 STENCIL_BACK_FAIL = 0x8801;
|
||||
const PRUint32 STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
|
||||
const PRUint32 STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
|
||||
const PRUint32 STENCIL_BACK_REF = 0x8CA3;
|
||||
const PRUint32 STENCIL_BACK_VALUE_MASK = 0x8CA4;
|
||||
const PRUint32 STENCIL_BACK_WRITEMASK = 0x8CA5;
|
||||
const PRUint32 VIEWPORT = 0x0BA2;
|
||||
const PRUint32 SCISSOR_BOX = 0x0C10;
|
||||
const PRUint32 COLOR_CLEAR_VALUE = 0x0C22;
|
||||
const PRUint32 COLOR_WRITEMASK = 0x0C23;
|
||||
const PRUint32 UNPACK_ALIGNMENT = 0x0CF5;
|
||||
const PRUint32 PACK_ALIGNMENT = 0x0D05;
|
||||
const PRUint32 MAX_TEXTURE_SIZE = 0x0D33;
|
||||
const PRUint32 MAX_VIEWPORT_DIMS = 0x0D3A;
|
||||
const PRUint32 SUBPIXEL_BITS = 0x0D50;
|
||||
const PRUint32 RED_BITS = 0x0D52;
|
||||
const PRUint32 GREEN_BITS = 0x0D53;
|
||||
const PRUint32 BLUE_BITS = 0x0D54;
|
||||
const PRUint32 ALPHA_BITS = 0x0D55;
|
||||
const PRUint32 DEPTH_BITS = 0x0D56;
|
||||
const PRUint32 STENCIL_BITS = 0x0D57;
|
||||
const PRUint32 POLYGON_OFFSET_UNITS = 0x2A00;
|
||||
const PRUint32 POLYGON_OFFSET_FACTOR = 0x8038;
|
||||
const PRUint32 TEXTURE_BINDING_2D = 0x8069;
|
||||
const PRUint32 SAMPLE_BUFFERS = 0x80A8;
|
||||
const PRUint32 SAMPLES = 0x80A9;
|
||||
const PRUint32 SAMPLE_COVERAGE_VALUE = 0x80AA;
|
||||
const PRUint32 SAMPLE_COVERAGE_INVERT = 0x80AB;
|
||||
const PRUint32 NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
|
||||
const PRUint32 COMPRESSED_TEXTURE_FORMATS = 0x86A3;
|
||||
const PRUint32 DONT_CARE = 0x1100;
|
||||
const PRUint32 FASTEST = 0x1101;
|
||||
const PRUint32 NICEST = 0x1102;
|
||||
const PRUint32 GENERATE_MIPMAP_HINT = 0x8192;
|
||||
const PRUint32 BYTE = 0x1400;
|
||||
const PRUint32 UNSIGNED_BYTE = 0x1401;
|
||||
const PRUint32 SHORT = 0x1402;
|
||||
const PRUint32 UNSIGNED_SHORT = 0x1403;
|
||||
const PRUint32 INT = 0x1404;
|
||||
const PRUint32 UNSIGNED_INT = 0x1405;
|
||||
const PRUint32 FLOAT = 0x1406;
|
||||
const PRUint32 FIXED = 0x140C;
|
||||
const PRUint32 DEPTH_COMPONENT = 0x1902;
|
||||
const PRUint32 ALPHA = 0x1906;
|
||||
const PRUint32 RGB = 0x1907;
|
||||
const PRUint32 RGBA = 0x1908;
|
||||
const PRUint32 LUMINANCE = 0x1909;
|
||||
const PRUint32 LUMINANCE_ALPHA = 0x190A;
|
||||
const PRUint32 UNSIGNED_SHORT_4_4_4_4 = 0x8033;
|
||||
const PRUint32 UNSIGNED_SHORT_5_5_5_1 = 0x8034;
|
||||
const PRUint32 UNSIGNED_SHORT_5_6_5 = 0x8363;
|
||||
const PRUint32 FRAGMENT_SHADER = 0x8B30;
|
||||
const PRUint32 VERTEX_SHADER = 0x8B31;
|
||||
const PRUint32 MAX_VERTEX_ATTRIBS = 0x8869;
|
||||
const PRUint32 MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
|
||||
const PRUint32 MAX_VARYING_VECTORS = 0x8DFC;
|
||||
const PRUint32 MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
|
||||
const PRUint32 MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
|
||||
const PRUint32 MAX_TEXTURE_IMAGE_UNITS = 0x8872;
|
||||
const PRUint32 MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;
|
||||
const PRUint32 SHADER_TYPE = 0x8B4F;
|
||||
const PRUint32 DELETE_STATUS = 0x8B80;
|
||||
const PRUint32 LINK_STATUS = 0x8B82;
|
||||
const PRUint32 VALIDATE_STATUS = 0x8B83;
|
||||
const PRUint32 ATTACHED_SHADERS = 0x8B85;
|
||||
const PRUint32 ACTIVE_UNIFORMS = 0x8B86;
|
||||
const PRUint32 ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87;
|
||||
const PRUint32 ACTIVE_ATTRIBUTES = 0x8B89;
|
||||
const PRUint32 ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A;
|
||||
const PRUint32 SHADING_LANGUAGE_VERSION = 0x8B8C;
|
||||
const PRUint32 CURRENT_PROGRAM = 0x8B8D;
|
||||
const PRUint32 NEVER = 0x0200;
|
||||
const PRUint32 LESS = 0x0201;
|
||||
const PRUint32 EQUAL = 0x0202;
|
||||
const PRUint32 LEQUAL = 0x0203;
|
||||
const PRUint32 GREATER = 0x0204;
|
||||
const PRUint32 NOTEQUAL = 0x0205;
|
||||
const PRUint32 GEQUAL = 0x0206;
|
||||
const PRUint32 ALWAYS = 0x0207;
|
||||
const PRUint32 KEEP = 0x1E00;
|
||||
const PRUint32 REPLACE = 0x1E01;
|
||||
const PRUint32 INCR = 0x1E02;
|
||||
const PRUint32 DECR = 0x1E03;
|
||||
const PRUint32 INVERT = 0x150A;
|
||||
const PRUint32 INCR_WRAP = 0x8507;
|
||||
const PRUint32 DECR_WRAP = 0x8508;
|
||||
const PRUint32 VENDOR = 0x1F00;
|
||||
const PRUint32 RENDERER = 0x1F01;
|
||||
const PRUint32 VERSION = 0x1F02;
|
||||
const PRUint32 EXTENSIONS = 0x1F03;
|
||||
const PRUint32 NEAREST = 0x2600;
|
||||
const PRUint32 LINEAR = 0x2601;
|
||||
const PRUint32 NEAREST_MIPMAP_NEAREST = 0x2700;
|
||||
const PRUint32 LINEAR_MIPMAP_NEAREST = 0x2701;
|
||||
const PRUint32 NEAREST_MIPMAP_LINEAR = 0x2702;
|
||||
const PRUint32 LINEAR_MIPMAP_LINEAR = 0x2703;
|
||||
const PRUint32 TEXTURE_MAG_FILTER = 0x2800;
|
||||
const PRUint32 TEXTURE_MIN_FILTER = 0x2801;
|
||||
const PRUint32 TEXTURE_WRAP_S = 0x2802;
|
||||
const PRUint32 TEXTURE_WRAP_T = 0x2803;
|
||||
const PRUint32 TEXTURE = 0x1702;
|
||||
const PRUint32 TEXTURE_CUBE_MAP = 0x8513;
|
||||
const PRUint32 TEXTURE_BINDING_CUBE_MAP = 0x8514;
|
||||
const PRUint32 TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
|
||||
const PRUint32 TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
|
||||
const PRUint32 TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
|
||||
const PRUint32 TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
|
||||
const PRUint32 TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
|
||||
const PRUint32 TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
|
||||
const PRUint32 MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
|
||||
const PRUint32 TEXTURE0 = 0x84C0;
|
||||
const PRUint32 TEXTURE1 = 0x84C1;
|
||||
const PRUint32 TEXTURE2 = 0x84C2;
|
||||
const PRUint32 TEXTURE3 = 0x84C3;
|
||||
const PRUint32 TEXTURE4 = 0x84C4;
|
||||
const PRUint32 TEXTURE5 = 0x84C5;
|
||||
const PRUint32 TEXTURE6 = 0x84C6;
|
||||
const PRUint32 TEXTURE7 = 0x84C7;
|
||||
const PRUint32 TEXTURE8 = 0x84C8;
|
||||
const PRUint32 TEXTURE9 = 0x84C9;
|
||||
const PRUint32 TEXTURE10 = 0x84CA;
|
||||
const PRUint32 TEXTURE11 = 0x84CB;
|
||||
const PRUint32 TEXTURE12 = 0x84CC;
|
||||
const PRUint32 TEXTURE13 = 0x84CD;
|
||||
const PRUint32 TEXTURE14 = 0x84CE;
|
||||
const PRUint32 TEXTURE15 = 0x84CF;
|
||||
const PRUint32 TEXTURE16 = 0x84D0;
|
||||
const PRUint32 TEXTURE17 = 0x84D1;
|
||||
const PRUint32 TEXTURE18 = 0x84D2;
|
||||
const PRUint32 TEXTURE19 = 0x84D3;
|
||||
const PRUint32 TEXTURE20 = 0x84D4;
|
||||
const PRUint32 TEXTURE21 = 0x84D5;
|
||||
const PRUint32 TEXTURE22 = 0x84D6;
|
||||
const PRUint32 TEXTURE23 = 0x84D7;
|
||||
const PRUint32 TEXTURE24 = 0x84D8;
|
||||
const PRUint32 TEXTURE25 = 0x84D9;
|
||||
const PRUint32 TEXTURE26 = 0x84DA;
|
||||
const PRUint32 TEXTURE27 = 0x84DB;
|
||||
const PRUint32 TEXTURE28 = 0x84DC;
|
||||
const PRUint32 TEXTURE29 = 0x84DD;
|
||||
const PRUint32 TEXTURE30 = 0x84DE;
|
||||
const PRUint32 TEXTURE31 = 0x84DF;
|
||||
const PRUint32 ACTIVE_TEXTURE = 0x84E0;
|
||||
const PRUint32 REPEAT = 0x2901;
|
||||
const PRUint32 CLAMP_TO_EDGE = 0x812F;
|
||||
const PRUint32 MIRRORED_REPEAT = 0x8370;
|
||||
const PRUint32 FLOAT_VEC2 = 0x8B50;
|
||||
const PRUint32 FLOAT_VEC3 = 0x8B51;
|
||||
const PRUint32 FLOAT_VEC4 = 0x8B52;
|
||||
const PRUint32 INT_VEC2 = 0x8B53;
|
||||
const PRUint32 INT_VEC3 = 0x8B54;
|
||||
const PRUint32 INT_VEC4 = 0x8B55;
|
||||
const PRUint32 BOOL = 0x8B56;
|
||||
const PRUint32 BOOL_VEC2 = 0x8B57;
|
||||
const PRUint32 BOOL_VEC3 = 0x8B58;
|
||||
const PRUint32 BOOL_VEC4 = 0x8B59;
|
||||
const PRUint32 FLOAT_MAT2 = 0x8B5A;
|
||||
const PRUint32 FLOAT_MAT3 = 0x8B5B;
|
||||
const PRUint32 FLOAT_MAT4 = 0x8B5C;
|
||||
const PRUint32 SAMPLER_2D = 0x8B5E;
|
||||
const PRUint32 SAMPLER_CUBE = 0x8B60;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
|
||||
const PRUint32 VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
|
||||
const PRUint32 IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A;
|
||||
const PRUint32 IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
|
||||
const PRUint32 COMPILE_STATUS = 0x8B81;
|
||||
const PRUint32 INFO_LOG_LENGTH = 0x8B84;
|
||||
const PRUint32 SHADER_SOURCE_LENGTH = 0x8B88;
|
||||
const PRUint32 SHADER_COMPILER = 0x8DFA;
|
||||
const PRUint32 SHADER_BINARY_FORMATS = 0x8DF8;
|
||||
const PRUint32 NUM_SHADER_BINARY_FORMATS = 0x8DF9;
|
||||
const PRUint32 LOW_FLOAT = 0x8DF0;
|
||||
const PRUint32 MEDIUM_FLOAT = 0x8DF1;
|
||||
const PRUint32 HIGH_FLOAT = 0x8DF2;
|
||||
const PRUint32 LOW_INT = 0x8DF3;
|
||||
const PRUint32 MEDIUM_INT = 0x8DF4;
|
||||
const PRUint32 HIGH_INT = 0x8DF5;
|
||||
const PRUint32 FRAMEBUFFER = 0x8D40;
|
||||
const PRUint32 RENDERBUFFER = 0x8D41;
|
||||
const PRUint32 RGBA4 = 0x8056;
|
||||
const PRUint32 RGB5_A1 = 0x8057;
|
||||
const PRUint32 RGB565 = 0x8D62;
|
||||
const PRUint32 DEPTH_COMPONENT16 = 0x81A5;
|
||||
const PRUint32 STENCIL_INDEX = 0x1901;
|
||||
const PRUint32 STENCIL_INDEX8 = 0x8D48;
|
||||
const PRUint32 RENDERBUFFER_WIDTH = 0x8D42;
|
||||
const PRUint32 RENDERBUFFER_HEIGHT = 0x8D43;
|
||||
const PRUint32 RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
|
||||
const PRUint32 RENDERBUFFER_RED_SIZE = 0x8D50;
|
||||
const PRUint32 RENDERBUFFER_GREEN_SIZE = 0x8D51;
|
||||
const PRUint32 RENDERBUFFER_BLUE_SIZE = 0x8D52;
|
||||
const PRUint32 RENDERBUFFER_ALPHA_SIZE = 0x8D53;
|
||||
const PRUint32 RENDERBUFFER_DEPTH_SIZE = 0x8D54;
|
||||
const PRUint32 RENDERBUFFER_STENCIL_SIZE = 0x8D55;
|
||||
const PRUint32 FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
|
||||
const PRUint32 FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
|
||||
const PRUint32 FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
|
||||
const PRUint32 FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
|
||||
const PRUint32 COLOR_ATTACHMENT0 = 0x8CE0;
|
||||
const PRUint32 DEPTH_ATTACHMENT = 0x8D00;
|
||||
const PRUint32 STENCIL_ATTACHMENT = 0x8D20;
|
||||
const PRUint32 NONE = 0;
|
||||
const PRUint32 FRAMEBUFFER_COMPLETE = 0x8CD5;
|
||||
const PRUint32 FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
|
||||
const PRUint32 FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
|
||||
const PRUint32 FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
|
||||
const PRUint32 FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
|
||||
const PRUint32 FRAMEBUFFER_BINDING = 0x8CA6;
|
||||
const PRUint32 RENDERBUFFER_BINDING = 0x8CA7;
|
||||
const PRUint32 MAX_RENDERBUFFER_SIZE = 0x84E8;
|
||||
const PRUint32 INVALID_FRAMEBUFFER_OPERATION = 0x0506;
|
||||
const PRUint32 MULTISAMPLE = 0x809D;
|
||||
|
||||
// Other
|
||||
void swapBuffers ();
|
||||
|
||||
};
|
|
@ -0,0 +1,91 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 canvas 3D.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsICanvasRenderingContextGL;
|
||||
|
||||
[scriptable, uuid(14eb51cd-febe-41fa-b833-4c599719121e)]
|
||||
interface nsICanvasRenderingContextGLBuffer : nsISupports
|
||||
{
|
||||
readonly attribute nsICanvasRenderingContextGL ownerContext;
|
||||
readonly attribute PRBool disposed;
|
||||
|
||||
// immediately free the memory held by this buffer,
|
||||
// even before this object is destroyed (e.g. by the JS GC)
|
||||
void dispose();
|
||||
|
||||
readonly attribute PRUint32 usage; // either STATIC_DRAW or DYNAMIC_DRAW
|
||||
readonly attribute PRUint32 length; // number of elements
|
||||
readonly attribute PRUint32 type; // type of each element
|
||||
};
|
||||
|
||||
[scriptable, uuid(27a45ca4-0847-4f2e-8e32-6d4966ff3e56)]
|
||||
interface nsICanvasRenderingContextGLTexture : nsISupports
|
||||
{
|
||||
readonly attribute nsICanvasRenderingContextGL ownerContext;
|
||||
readonly attribute PRBool disposed;
|
||||
|
||||
const PRUint32 TARGET_2D = 0;
|
||||
const PRUint32 TARGET_RECT = 1;
|
||||
|
||||
readonly attribute PRUint32 target;
|
||||
|
||||
// in pixels; the texture coordinates
|
||||
// are 0..w/h for TARGET_RECT, or 0.0 .. 1.0
|
||||
// for TARGET_2D
|
||||
readonly attribute PRUint32 width;
|
||||
readonly attribute PRUint32 height;
|
||||
|
||||
const PRUint32 FILTER_TYPE_MAG = 0;
|
||||
const PRUint32 FILTER_TYPE_MIN = 1;
|
||||
const PRUint32 FILTER_NEAREST = 0;
|
||||
const PRUint32 FILTER_LINER = 1;
|
||||
|
||||
void setFilter (in PRUint32 filterType, in PRUint32 filterMode);
|
||||
|
||||
const PRUint32 WRAP_TYPE_S = 0;
|
||||
const PRUint32 WRAP_TYPE_T = 0;
|
||||
|
||||
const PRUint32 WRAP_CLAMP_TO_EDGE = 1;
|
||||
const PRUint32 WRAP_REPEAT = 3;
|
||||
const PRUint32 WRAP_MIRRORED_REPEAT = 4;
|
||||
|
||||
void setWrap (in PRUint32 wrapType, in PRUint32 wrapMode);
|
||||
};
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 canvas 3D.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#include "nsICanvasRenderingContextGL.idl"
|
||||
#include "nsICanvasRenderingContextGLBuffer.idl"
|
||||
|
||||
interface nsIDOMHTMLElement;
|
||||
|
||||
[scriptable, uuid(209a9c93-495e-4085-a3e4-29354b404cc4)]
|
||||
interface nsICanvasRenderingContextGLWeb20 : nsICanvasRenderingContextGL
|
||||
{
|
||||
void activeTexture (in PRUint32 texture);
|
||||
|
||||
void attachShader (in PRUint32 program, in PRUint32 shader);
|
||||
void bindAttribLocation (in PRUint32 program, in PRUint32 index, in string name);
|
||||
|
||||
void bindBuffer (in PRUint32 target, in PRUint32 buffer);
|
||||
void bindTexture (in PRUint32 target, in PRUint32 texid);
|
||||
|
||||
void blendColor (in float red, in float green, in float blue, in float alpha);
|
||||
void blendEquation (in PRUint32 mode);
|
||||
void blendEquationSeparate (in PRUint32 modeRGB, in PRUint32 modeAlpha);
|
||||
void blendFunc (in PRUint32 sfactor, in PRUint32 dfactor);
|
||||
void blendFuncSeparate (in PRUint32 srcRGB, in PRUint32 dstRGB, in PRUint32 srcAlpha, in PRUint32 dstAlpha);
|
||||
|
||||
|
||||
void bufferData (/*in PRUint32 target, in object[] array, in PRUint32 type, in PRUint32 usage*/);
|
||||
void bufferSubData (/*in PRUint32 target, in PRUint32 offset, in object[] array, in PRUint32 type*/);
|
||||
|
||||
void clear (in PRUint32 mask);
|
||||
void clearColor (in float red, in float green, in float blue, in float alpha);
|
||||
void clearDepth (in float depth);
|
||||
void clearStencil (in PRInt32 s);
|
||||
void colorMask (in boolean red, in boolean green, in boolean blue, in boolean alpha);
|
||||
// NO compressedTexImage2D
|
||||
// NO compressedTexSubImage2D
|
||||
|
||||
void copyTexImage2D (in PRUint32 target, in PRInt32 level, in PRUint32 internalFormat, in PRInt32 x, in PRInt32 y, in PRUint32 width, in PRUint32 height, in PRInt32 border);
|
||||
void copyTexSubImage2D (in PRUint32 target, in PRInt32 level, in PRInt32 xoffset, in PRInt32 yoffset, in PRInt32 x, in PRInt32 y, in PRUint32 width, in PRUint32 height);
|
||||
|
||||
PRUint32 createProgram ();
|
||||
PRUint32 createShader (in PRUint32 type);
|
||||
void cullFace (in PRUint32 face);
|
||||
|
||||
void deleteBuffers (/*in PRUint32[] buffers*/);
|
||||
void deleteTextures (/*in PRUint32[] textures*/);
|
||||
void deleteProgram (in PRUint32 program);
|
||||
void deleteShader (in PRUint32 shader);
|
||||
void detachShader (in PRUint32 program, in PRUint32 shader);
|
||||
void depthFunc (in PRUint32 func);
|
||||
void depthMask (in boolean flag);
|
||||
void depthRange (in float zNear, in float zFar);
|
||||
void disable (in PRUint32 mode);
|
||||
void disableVertexAttribArray (in PRUint32 index);
|
||||
void drawArrays (in PRUint32 mode, in PRUint32 first, in PRUint32 count);
|
||||
void drawElements (/*in PRUint32 mode, in PRUint32 count, in PRUint32 type, in PRUint32[] indices*/);
|
||||
void enable (in PRUint32 mode);
|
||||
void enableVertexAttribArray (in PRUint32 index);
|
||||
void finish();
|
||||
void flush();
|
||||
void frontFace (in PRUint32 face);
|
||||
|
||||
// getActiveAttrib returns an object: { name: "..", size: .., type: .. }
|
||||
void getActiveAttrib (in PRUint32 program, in PRUint32 index);
|
||||
|
||||
// getActiveUniform returns an object: { name: "..", size: .., type: .. }
|
||||
void getActiveUniform (in PRUint32 program, in PRUint32 index);
|
||||
|
||||
// returns an array of shader IDs
|
||||
void getAttachedShaders (in PRUint32 program);
|
||||
|
||||
PRInt32 getAttribLocation (in PRUint32 program, in string name);
|
||||
|
||||
// getBooleanv, getIntegerv, getFloatv, getDoublev, getString
|
||||
// are all rolled into a single function that uses scriptable
|
||||
// magic to return the right type of jsobj. Colors are always
|
||||
// returned as normalized floats (0.0 .. 1.0).
|
||||
|
||||
void getParameter (in PRUint32 pname);
|
||||
void getBufferParameter (in PRUint32 target, in PRUint32 pname);
|
||||
|
||||
void genBuffers (in PRUint32 n);
|
||||
void genTextures (in PRUint32 n);
|
||||
|
||||
void generateMipmap (in PRUint32 target);
|
||||
|
||||
PRUint32 getError ();
|
||||
|
||||
void getProgramParameter (in PRUint32 program, in PRUint32 pname);
|
||||
|
||||
string getProgramInfoLog (in PRUint32 program);
|
||||
|
||||
void getTexParameter(in PRUint32 target, in PRUint32 pname);
|
||||
|
||||
void getUniform (in PRUint32 program, in PRUint32 location);
|
||||
PRInt32 getUniformLocation (in PRUint32 program, in string name);
|
||||
|
||||
void getVertexAttrib (in PRUint32 index, in PRUint32 pname);
|
||||
// NO void getVertexAttribPointerv
|
||||
|
||||
void hint (in PRUint32 target, in PRUint32 mode);
|
||||
|
||||
boolean isBuffer (in PRUint32 buffer);
|
||||
boolean isEnabled (in PRUint32 cap);
|
||||
boolean isProgram (in PRUint32 program);
|
||||
boolean isShader (in PRUint32 shader);
|
||||
boolean isTexture (in PRUint32 texture);
|
||||
|
||||
void lineWidth (in float width);
|
||||
void linkProgram (in PRUint32 program);
|
||||
|
||||
// NO pixelStore
|
||||
|
||||
void pixelStore (in PRUint32 pname, in PRInt32 param);
|
||||
|
||||
void polygonOffset (in float factor, in float units);
|
||||
|
||||
void readPixels (in PRUint32 x, in PRUint32 y, in PRUint32 width, in PRUint32 height, in PRUint32 format, in PRUint32 type);
|
||||
|
||||
void sampleCoverage (in float value, in boolean invert);
|
||||
void scissor (in PRInt32 x, in PRInt32 y, in PRInt32 width, in PRInt32 height);
|
||||
void stencilFunc (in PRUint32 func, in PRInt32 ref, in PRUint32 mask);
|
||||
void stencilFuncSeparate (in PRUint32 face, in PRUint32 func, in PRInt32 ref, in PRUint32 mask);
|
||||
void stencilMask (in PRUint32 mask);
|
||||
void stencilMaskSeparate (in PRUint32 face, in PRUint32 mask);
|
||||
void stencilOp (in PRUint32 fail, in PRUint32 zfail, in PRUint32 zpass);
|
||||
void stencilOpSeparate (in PRUint32 face, in PRUint32 fail, in PRUint32 zfail, in PRUint32 zpass);
|
||||
|
||||
void texSubImage2D ();
|
||||
void texImage2D ();
|
||||
void texSubImage2DHTML (in PRUint32 target, in PRUint32 level, in PRInt32 x, in PRInt32 y, in nsIDOMHTMLElement imageOrCanvas);
|
||||
void texImage2DHTML (in PRUint32 target, in PRUint32 level, in nsIDOMHTMLElement imageOrCanvas);
|
||||
|
||||
void texParameter();
|
||||
|
||||
// YES void texSubImage2DHTML (...);
|
||||
|
||||
void uniform1i(in PRUint32 id, in PRInt32 x);
|
||||
void uniform2i(in PRUint32 id, in PRInt32 x, in PRInt32 y);
|
||||
void uniform3i(in PRUint32 id, in PRInt32 x, in PRInt32 y, in PRInt32 z);
|
||||
void uniform4i(in PRUint32 id, in PRInt32 x, in PRInt32 y, in PRInt32 z, in PRInt32 w);
|
||||
|
||||
void uniform1iv(/*in PRUint32 id, in int[] array */);
|
||||
void uniform2iv(/*in PRUint32 id, in int[] array */);
|
||||
void uniform3iv(/*in PRUint32 id, in int[] array */);
|
||||
void uniform4iv(/*in PRUint32 id, in int[] array */);
|
||||
|
||||
void uniform1f(in PRUint32 id, in float x);
|
||||
void uniform2f(in PRUint32 id, in float x, in float y);
|
||||
void uniform3f(in PRUint32 id, in float x, in float y, in float z);
|
||||
void uniform4f(in PRUint32 id, in float x, in float y, in float z, in float w);
|
||||
|
||||
void uniform1fv(/*in PRUint32 id, in float[] array */);
|
||||
void uniform2fv(/*in PRUint32 id, in float[] array */);
|
||||
void uniform3fv(/*in PRUint32 id, in float[] array */);
|
||||
void uniform4fv(/*in PRUint32 id, in float[] array */);
|
||||
|
||||
void uniformMatrix2fv(/*in PRUint32 id, in float[] array */);
|
||||
void uniformMatrix3fv(/*in PRUint32 id, in float[] array */);
|
||||
void uniformMatrix4fv(/*in PRUint32 id, in float[] array */);
|
||||
|
||||
void useProgram (in PRUint32 program);
|
||||
void validateProgram (in PRUint32 program);
|
||||
|
||||
void vertexAttrib1f(in PRUint32 id, in float x);
|
||||
void vertexAttrib2f(in PRUint32 id, in float x, in float y);
|
||||
void vertexAttrib3f(in PRUint32 id, in float x, in float y, in float z);
|
||||
void vertexAttrib4f(in PRUint32 id, in float x, in float y, in float z, in float w);
|
||||
|
||||
void vertexAttrib1fv(/*in PRUint32 id, in float[] array*/);
|
||||
void vertexAttrib2fv(/*in PRUint32 id, in float[] array*/);
|
||||
void vertexAttrib3fv(/*in PRUint32 id, in float[] array*/);
|
||||
void vertexAttrib4fv(/*in PRUint32 id, in float[] array*/);
|
||||
|
||||
void vertexAttribPointer (/*in PRUint32 index, in PRInt32 size, in PRUint32 type, in PRBool normalized, in PRUint32 stride, in Object[] array*/);
|
||||
|
||||
void viewport (in PRInt32 x, in PRInt32 y, in PRInt32 width, in PRInt32 height);
|
||||
|
||||
void compileShader (in PRUint32 shader);
|
||||
void getShaderParameter (in PRUint32 shader, in PRUint32 pname);
|
||||
string getShaderInfoLog (in PRUint32 shader);
|
||||
string getShaderSource (in PRUint32 shader);
|
||||
void shaderSource(in PRUint32 shader, in string source);
|
||||
|
||||
void getImageData (in PRUint32 x, in PRUint32 y, in PRUint32 width, in PRUint32 height);
|
||||
|
||||
//
|
||||
// framebuffer_object methods
|
||||
//
|
||||
|
||||
void bindRenderbuffer (in PRUint32 target, in PRUint32 renderbuffer);
|
||||
boolean isRenderbuffer (in PRUint32 renderbuffer);
|
||||
void deleteRenderbuffers (/*in PRUint32[] renderbuffers*/);
|
||||
void genRenderbuffers (in PRUint32 n);
|
||||
|
||||
void renderbufferStorage (in PRUint32 target, in PRUint32 internalFormat, in PRUint32 width, in PRUint32 height);
|
||||
|
||||
void getRenderbufferParameter (in PRUint32 target, in PRUint32 pname);
|
||||
|
||||
void bindFramebuffer (in PRUint32 target, in PRUint32 framebuffer);
|
||||
boolean isFramebuffer (in PRUint32 framebuffer);
|
||||
void deleteFramebuffers (/*in PRUint32[] framebuffers*/);
|
||||
void genFramebuffers (in PRUint32 n);
|
||||
|
||||
PRUint32 checkFramebufferStatus (in PRUint32 target);
|
||||
|
||||
void framebufferTexture2D (in PRUint32 target, in PRUint32 attachmentPoint, in PRUint32 textureTarget, in PRUint32 texture, in PRInt32 level);
|
||||
|
||||
void framebufferRenderbuffer (in PRUint32 target, in PRUint32 attachmentPoint, in PRUint32 renderbufferTarget, in PRUint32 renderbuffer);
|
||||
|
||||
void getFramebufferAttachmentParameter (in PRUint32 target, in PRUint32 attachment, in PRUint32 pname);
|
||||
|
||||
};
|
||||
|
|
@ -265,9 +265,11 @@ endif
|
|||
EXTRA_DSO_LDOPTS += $(MOZ_LOCATION_LIBS)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
EXTRA_DSO_LDOPTS += -framework OpenGL
|
||||
endif
|
||||
endif
|
||||
|
||||
# Add explicit X11 dependency when building against X11 toolkits
|
||||
|
|
|
@ -214,6 +214,10 @@
|
|||
#define NS_CANVASRENDERINGCONTEXT2D_CID \
|
||||
{ 0xa35d1cd4, 0xc505, 0x4d2d, { 0xa0, 0xf9, 0xae, 0xf0, 0x0b, 0x7c, 0xe5, 0xa5 } }
|
||||
|
||||
// {2fe88332-31c6-4829-b247-a07d8a73e80e}
|
||||
#define NS_CANVASRENDERINGCONTEXTGLWEB20_CID \
|
||||
{ 0x2fe88332, 0x31c6, 0x4829, { 0xb2, 0x47, 0xa0, 0x7d, 0x8a, 0x7e, 0xe8, 0x0e } }
|
||||
|
||||
// {8b449142-1eab-4bfa-9830-fab6ebb09774}
|
||||
#define NS_DOMSTORAGE_CID \
|
||||
{ 0x8b449142, 0x1eab, 0x4bfa, { 0x98, 0x30, 0xfa, 0xb6, 0xeb, 0xb0, 0x97, 0x74 } }
|
||||
|
|
|
@ -210,6 +210,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLEditor)
|
|||
|
||||
#ifdef MOZ_ENABLE_CANVAS
|
||||
#include "nsIDOMCanvasRenderingContext2D.h"
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
#include "nsICanvasRenderingContextGLWeb20.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class nsIDocumentLoaderFactory;
|
||||
|
@ -404,6 +407,9 @@ nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
|
|||
|
||||
#ifdef MOZ_ENABLE_CANVAS
|
||||
nsresult NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult);
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
nsresult NS_NewCanvasRenderingContextGLWeb20(nsICanvasRenderingContextGLWeb20** aResult);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
|
||||
|
@ -540,6 +546,9 @@ MAKE_CTOR(CreateFocusManager, nsIFocusManager, NS_NewFocusManag
|
|||
|
||||
#ifdef MOZ_ENABLE_CANVAS
|
||||
MAKE_CTOR(CreateCanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D, NS_NewCanvasRenderingContext2D)
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
MAKE_CTOR(CreateCanvasRenderingContextGLWeb20, nsICanvasRenderingContextGLWeb20, NS_NewCanvasRenderingContextGLWeb20)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init)
|
||||
|
@ -1080,6 +1089,12 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||
NS_CANVASRENDERINGCONTEXT2D_CID,
|
||||
"@mozilla.org/content/canvas-rendering-context;1?id=2d",
|
||||
CreateCanvasRenderingContext2D },
|
||||
#ifdef MOZ_ENABLE_CANVAS3D
|
||||
{ "Canvas OpenGL Web 2.0 Rendering Context",
|
||||
NS_CANVASRENDERINGCONTEXTGLWEB20_CID,
|
||||
"@mozilla.org/content/canvas-rendering-context;1?id=moz-glweb20",
|
||||
CreateCanvasRenderingContextGLWeb20 },
|
||||
#endif
|
||||
#endif
|
||||
|
||||
{ "XML document encoder",
|
||||
|
|
|
@ -362,3 +362,10 @@ endif
|
|||
ifdef GC_LEAK_DETECTOR
|
||||
EXTRA_DSO_LIBS += boehm
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
EXTRA_DSO_LDOPTS += -framework OpenGL
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче