npotb; canvas 3d updates/fixes

This commit is contained in:
vladimir@pobox.com 2007-10-21 12:19:15 -07:00
Родитель fabec04cd3
Коммит 8e8c3cb648
9 изменённых файлов: 221 добавлений и 49 удалений

Просмотреть файл

@ -4,7 +4,7 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>canvas3d@mozilla.com</em:id>
<em:version>0.1</em:version>
<em:version>0.1.18</em:version>
<em:type>2</em:type>
@ -17,7 +17,7 @@
to internal interfaces.
-->
<em:minVersion>3.0a8pre</em:minVersion>
<em:maxVersion>3.0a8pre</em:maxVersion>
<em:maxVersion>3.0</em:maxVersion>
</Description>
</em:targetApplication>

Просмотреть файл

@ -54,6 +54,8 @@ MODULE_NAME = nsCanvas3DModule
GRE_MODULE = 1
BUILD_STATIC_LIBS =
USE_STATIC_LIBS = 1
REQUIRES = \
xpcom \
string \

Просмотреть файл

@ -4858,6 +4858,30 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
#ifdef GL_VERSION_2_0
if (glewExperimental || GLEW_VERSION_2_0) GLEW_VERSION_2_0 = !_glewInit_GL_VERSION_2_0(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_VERSION_2_0 */
/* Canvas3D Extensions */
#ifdef GL_ARB_multitexture
GLEW_ARB_multitexture = glewGetExtension("GL_ARB_multitexture");
if (glewExperimental || GLEW_ARB_multitexture) GLEW_ARB_multitexture = !_glewInit_GL_ARB_multitexture(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_ARB_multitexture */
#ifdef GL_ARB_point_parameters
GLEW_ARB_point_parameters = glewGetExtension("GL_ARB_point_parameters");
if (glewExperimental || GLEW_ARB_point_parameters) GLEW_ARB_point_parameters = !_glewInit_GL_ARB_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_ARB_point_parameters */
#ifdef GL_ARB_texture_rectangle
GLEW_ARB_texture_rectangle = glewGetExtension("GL_ARB_texture_rectangle");
#endif /* GL_ARB_texture_rectangle */
#ifdef GL_EXT_texture_filter_anisotropic
GLEW_EXT_texture_filter_anisotropic = glewGetExtension("GL_EXT_texture_filter_anisotropic");
#endif /* GL_EXT_texture_filter_anisotropic */
/* unused extensions */
#if 0
#ifdef GL_EXT_point_parameters
GLEW_EXT_point_parameters = glewGetExtension("GL_EXT_point_parameters");
if (glewExperimental || GLEW_EXT_point_parameters) GLEW_EXT_point_parameters = !_glewInit_GL_EXT_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_EXT_point_parameters */
#ifdef GL_3DFX_multisample
GLEW_3DFX_multisample = glewGetExtension("GL_3DFX_multisample");
#endif /* GL_3DFX_multisample */
@ -4941,10 +4965,6 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
GLEW_ARB_multisample = glewGetExtension("GL_ARB_multisample");
if (glewExperimental || GLEW_ARB_multisample) GLEW_ARB_multisample = !_glewInit_GL_ARB_multisample(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_ARB_multisample */
#ifdef GL_ARB_multitexture
GLEW_ARB_multitexture = glewGetExtension("GL_ARB_multitexture");
if (glewExperimental || GLEW_ARB_multitexture) GLEW_ARB_multitexture = !_glewInit_GL_ARB_multitexture(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_ARB_multitexture */
#ifdef GL_ARB_occlusion_query
GLEW_ARB_occlusion_query = glewGetExtension("GL_ARB_occlusion_query");
if (glewExperimental || GLEW_ARB_occlusion_query) GLEW_ARB_occlusion_query = !_glewInit_GL_ARB_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT);
@ -4952,10 +4972,6 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
#ifdef GL_ARB_pixel_buffer_object
GLEW_ARB_pixel_buffer_object = glewGetExtension("GL_ARB_pixel_buffer_object");
#endif /* GL_ARB_pixel_buffer_object */
#ifdef GL_ARB_point_parameters
GLEW_ARB_point_parameters = glewGetExtension("GL_ARB_point_parameters");
if (glewExperimental || GLEW_ARB_point_parameters) GLEW_ARB_point_parameters = !_glewInit_GL_ARB_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_ARB_point_parameters */
#ifdef GL_ARB_point_sprite
GLEW_ARB_point_sprite = glewGetExtension("GL_ARB_point_sprite");
#endif /* GL_ARB_point_sprite */
@ -5003,9 +5019,6 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
#ifdef GL_ARB_texture_non_power_of_two
GLEW_ARB_texture_non_power_of_two = glewGetExtension("GL_ARB_texture_non_power_of_two");
#endif /* GL_ARB_texture_non_power_of_two */
#ifdef GL_ARB_texture_rectangle
GLEW_ARB_texture_rectangle = glewGetExtension("GL_ARB_texture_rectangle");
#endif /* GL_ARB_texture_rectangle */
#ifdef GL_ARB_transpose_matrix
GLEW_ARB_transpose_matrix = glewGetExtension("GL_ARB_transpose_matrix");
if (glewExperimental || GLEW_ARB_transpose_matrix) GLEW_ARB_transpose_matrix = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT);
@ -5242,10 +5255,6 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
#ifdef GL_EXT_pixel_transform_color_table
GLEW_EXT_pixel_transform_color_table = glewGetExtension("GL_EXT_pixel_transform_color_table");
#endif /* GL_EXT_pixel_transform_color_table */
#ifdef GL_EXT_point_parameters
GLEW_EXT_point_parameters = glewGetExtension("GL_EXT_point_parameters");
if (glewExperimental || GLEW_EXT_point_parameters) GLEW_EXT_point_parameters = !_glewInit_GL_EXT_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_EXT_point_parameters */
#ifdef GL_EXT_polygon_offset
GLEW_EXT_polygon_offset = glewGetExtension("GL_EXT_polygon_offset");
if (glewExperimental || GLEW_EXT_polygon_offset) GLEW_EXT_polygon_offset = !_glewInit_GL_EXT_polygon_offset(GLEW_CONTEXT_ARG_VAR_INIT);
@ -5315,9 +5324,6 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
#ifdef GL_EXT_texture_env_dot3
GLEW_EXT_texture_env_dot3 = glewGetExtension("GL_EXT_texture_env_dot3");
#endif /* GL_EXT_texture_env_dot3 */
#ifdef GL_EXT_texture_filter_anisotropic
GLEW_EXT_texture_filter_anisotropic = glewGetExtension("GL_EXT_texture_filter_anisotropic");
#endif /* GL_EXT_texture_filter_anisotropic */
#ifdef GL_EXT_texture_lod_bias
GLEW_EXT_texture_lod_bias = glewGetExtension("GL_EXT_texture_lod_bias");
#endif /* GL_EXT_texture_lod_bias */
@ -5760,6 +5766,8 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
if (glewExperimental || GLEW_WIN_swap_hint) GLEW_WIN_swap_hint = !_glewInit_GL_WIN_swap_hint(GLEW_CONTEXT_ARG_VAR_INIT);
#endif /* GL_WIN_swap_hint */
#endif /* #if 0'd unused extensions */
return GLEW_OK;
}

Просмотреть файл

@ -437,6 +437,15 @@ JSArrayToSimpleBuffer (SimpleBuffer& sbuffer,
::JS_ValueToECMAUint32(ctx, jv, &iv);
*ptr++ = (unsigned char) iv;
}
} else if (typeParam == GL_UNSIGNED_SHORT) {
PRUint16 *ptr = (PRUint16*) sbuffer.data;
for (PRUint32 i = 0; i < arrayLen; i++) {
jsval jv;
uint32 iv;
::JS_GetElement(ctx, arrayObj, i, &jv);
::JS_ValueToECMAUint32(ctx, jv, &iv);
*ptr++ = (unsigned short) iv;
}
} else if (typeParam == GL_UNSIGNED_INT) {
PRUint32 *ptr = (PRUint32*) sbuffer.data;
for (PRUint32 i = 0; i < arrayLen; i++) {
@ -474,14 +483,45 @@ nsCanvasRenderingContextGLPrivate::LostCurrentContext(void *closure)
NS_IMETHODIMP
nsCanvasRenderingContextGLPrivate::SetCanvasElement(nsICanvasElement* aParentCanvas)
{
nsresult rv;
if (aParentCanvas == nsnull) {
// we get this on shutdown; we should do some more cleanup here,
// but instead we just let our destructor do it.
return NS_OK;
}
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: hello?"));
if (!SafeToCreateCanvas3DContext())
return NS_ERROR_FAILURE;
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: is anyone there?"));
mGLPbuffer = new nsGLPbuffer();
if (!mGLPbuffer->Init(this))
return NS_ERROR_FAILURE;
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: it's dark in here."));
// Let's find our prefs
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mPrefWireframe = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
if (NS_SUCCEEDED(rv)) {
PRBool val;
rv = prefBranch->GetBoolPref("wireframe", &val);
if (NS_SUCCEEDED(rv))
mPrefWireframe = val;
}
fprintf (stderr, "Wireframe: %d\n", mPrefWireframe);
if (!ValidateGL()) {
// XXX over here we need to destroy mGLPbuffer and create a mesa buffer
@ -499,6 +539,8 @@ nsCanvasRenderingContextGLPrivate::SetDimensions(PRInt32 width, PRInt32 height)
{
fprintf (stderr, "VVVV CanvasGLBuffer::SetDimensions %d %d\n", width, height);
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: look! there's a light!"));
if (mWidth == width && mHeight == height)
return NS_OK;
@ -507,6 +549,8 @@ nsCanvasRenderingContextGLPrivate::SetDimensions(PRInt32 width, PRInt32 height)
return NS_ERROR_FAILURE;
}
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: maybe that's the way out."));
mWidth = width;
mHeight = height;
@ -525,7 +569,11 @@ nsCanvasRenderingContextGLPrivate::Render(gfxContext *ctx)
return NS_OK;
nsRefPtr<gfxASurface> surf = mGLPbuffer->ThebesSurface();
nsRefPtr<gfxPattern> pat = new gfxPattern(surf);
nsRefPtr<gfxPattern> pat = CanvasGLThebes::CreatePattern(surf);
gfxMatrix m;
m.Translate(gfxPoint(0.0, mGLPbuffer->Height()));
m.Scale(1.0, -1.0);
pat->SetMatrix(m);
// XXX I don't want to use PixelSnapped here, but layout doesn't guarantee
// pixel alignment for this stuff!
@ -569,6 +617,11 @@ nsCanvasRenderingContextGLPrivate::CairoSurfaceFromElement(nsIDOMElement *imgElt
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
return NS_ERROR_NOT_AVAILABLE;
PRUint32 status;
imgRequest->GetImageStatus(&status);
if ((status & imgIRequest::STATUS_LOAD_COMPLETE) == 0)
return NS_ERROR_NOT_AVAILABLE;
nsCOMPtr<nsIURI> uri;
rv = imageLoader->GetCurrentURI(uriOut);
NS_ENSURE_SUCCESS(rv, rv);
@ -586,8 +639,8 @@ nsCanvasRenderingContextGLPrivate::CairoSurfaceFromElement(nsIDOMElement *imgElt
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<gfxImageSurface> surf =
new gfxImageSurface (gfxIntSize(w, h), gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> ctx = new gfxContext(surf);
CanvasGLThebes::CreateImageSurface(gfxIntSize(w, h), gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> ctx = CanvasGLThebes::CreateContext(surf);
ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
ctx->Paint();
ctx->SetOperator(gfxContext::OPERATOR_OVER);
@ -723,6 +776,8 @@ nsCanvasRenderingContextGLPrivate::nsCanvasRenderingContextGLPrivate()
} else {
NS_ADDREF(gJSRuntimeService);
}
LogMessage(NS_LITERAL_CSTRING("Canvas 3D: where am I?"));
}
nsCanvasRenderingContextGLPrivate::~nsCanvasRenderingContextGLPrivate()
@ -790,6 +845,28 @@ nsCanvasRenderingContextGLPrivate::SafeToCreateCanvas3DContext()
return PR_FALSE;
}
gfxImageSurface *
CanvasGLThebes::CreateImageSurface (const gfxIntSize &isize,
gfxASurface::gfxImageFormat fmt)
{
/*void *p = NS_Alloc(sizeof(gfxImageSurface));*/
return new /*(p)*/ gfxImageSurface (isize, fmt);
}
gfxContext *
CanvasGLThebes::CreateContext (gfxASurface *surf)
{
void *p = NS_Alloc(sizeof(gfxContext));
return new (p) gfxContext (surf);
}
gfxPattern *
CanvasGLThebes::CreatePattern (gfxASurface *surf)
{
/*void *p = NS_Alloc(sizeof(gfxPattern));*/
return new /*(p)*/ gfxPattern(surf);
}
/*
* We need this here, because nsAString has a different type name based on whether it's
* used internally or externally. BeginPrinting isn't ever called, but gfxImageSurface

Просмотреть файл

@ -143,6 +143,8 @@ protected:
PRInt32 mWidth, mHeight;
nsICanvasElement* mCanvasElement;
PRPackedBool mPrefWireframe;
static inline PRBool JSValToFloatArray (JSContext *ctx, jsval val,
jsuint cnt, float *array)
{
@ -152,6 +154,7 @@ protected:
jsdouble dv;
if (!::JS_ValueToObject(ctx, val, &arrayObj) ||
arrayObj == NULL ||
!::JS_IsArrayObject(ctx, arrayObj) ||
!::JS_GetArrayLength(ctx, arrayObj, &arrayLen) ||
(arrayLen < cnt))
@ -176,6 +179,7 @@ protected:
jsdouble dv;
if (!::JS_ValueToObject(ctx, val, &arrayObj) ||
arrayObj == NULL ||
!::JS_IsArrayObject(ctx, arrayObj) ||
!::JS_GetArrayLength(ctx, arrayObj, &arrayLen) ||
(arrayLen < cnt))
@ -197,6 +201,7 @@ protected:
JSObject *obj = nsnull;
jsuint len;
if (!::JS_ValueToObject(ctx, val, &obj) ||
obj == NULL ||
!::JS_IsArrayObject(ctx, obj) ||
!::JS_GetArrayLength(ctx, obj, &len))
{
@ -259,7 +264,8 @@ protected:
void LogMessage (const nsCString& errorString) {
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
console->LogStringMessage(NS_ConvertUTF8toUTF16(errorString).get());
if (console)
console->LogStringMessage(NS_ConvertUTF8toUTF16(errorString).get());
}
};
@ -607,6 +613,16 @@ protected:
GLuint mBufferID;
};
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.

Просмотреть файл

@ -1147,10 +1147,11 @@ nsCanvasRenderingContextGLES11::TexImage2DHTML(PRUint32 target, nsIDOMHTMLElemen
}
if (!image_data) {
nsRefPtr<gfxImageSurface> tmpImageSurface = new gfxImageSurface(gfxIntSize(width, height),
gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> cx = new gfxContext(tmpImageSurface);
nsRefPtr<gfxImageSurface> tmpImageSurface =
CanvasGLThebes::CreateImageSurface(gfxIntSize(width, height),
gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> cx =
CanvasGLThebes::CreateContext(tmpImageSurface);
cx->SetSource(surf);
cx->SetOperator(gfxContext::OPERATOR_SOURCE);
cx->Paint();
@ -1872,6 +1873,7 @@ nsCanvasRenderingContextGLES11::BufferData()
jsuint type;
jsuint usage;
if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uouu", &target, &arrayObj, &type, &usage) ||
arrayObj == NULL ||
!::JS_IsArrayObject(js.ctx, arrayObj) ||
!::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
{
@ -1905,6 +1907,7 @@ nsCanvasRenderingContextGLES11::BufferSubData()
jsuint offset;
jsuint type;
if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuou", &target, &offset, &arrayObj, &type) ||
arrayObj == NULL ||
!::JS_IsArrayObject(js.ctx, arrayObj) ||
!::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
{

Просмотреть файл

@ -41,6 +41,8 @@
#include "nsIRenderingContext.h"
#include "nsTArray.h"
#define NSGL_CONTEXT_NAME nsCanvasRenderingContextGLWeb20
#include "nsCanvasRenderingContextGL.h"
@ -114,6 +116,9 @@ public:
// nsICanvasRenderingContextPrivate
virtual nsICanvasRenderingContextGL *GetSelf() { return this; }
virtual PRBool ValidateGL();
protected:
nsTArray<nsRefPtr<CanvasGLBuffer> > mAttribBuffers;
};
@ -215,6 +220,7 @@ nsCanvasRenderingContextGLWeb20::BufferData()
jsuint type;
jsuint usage;
if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uouu", &target, &arrayObj, &type, &usage) ||
arrayObj == NULL ||
!::JS_IsArrayObject(js.ctx, arrayObj) ||
!::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
{
@ -248,6 +254,7 @@ nsCanvasRenderingContextGLWeb20::BufferSubData()
jsuint offset;
jsuint type;
if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuou", &target, &offset, &arrayObj, &type) ||
arrayObj == NULL ||
!::JS_IsArrayObject(js.ctx, arrayObj) ||
!::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
{
@ -372,7 +379,34 @@ GL_SAME_METHOD_3(DrawArrays, DrawArrays, PRUint32, PRUint32, PRUint32)
NS_IMETHODIMP
nsCanvasRenderingContextGLWeb20::DrawElements()
{
return NS_ERROR_NOT_IMPLEMENTED;
NativeJSContext js;
if (NS_FAILED(js.error))
return js.error;
if (js.argc != 3)
return NS_ERROR_DOM_SYNTAX_ERR;
JSObject *arrayObj;
jsuint arrayLen;
jsuint mode;
jsuint count;
if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuo", &mode, &count, &arrayObj) ||
arrayObj == NULL ||
!::JS_IsArrayObject(js.ctx, arrayObj) ||
!::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
{
return NS_ERROR_DOM_SYNTAX_ERR;
}
SimpleBuffer sbuffer;
nsresult rv = JSArrayToSimpleBuffer(sbuffer, GL_UNSIGNED_SHORT, 1, js.ctx, arrayObj, arrayLen);
if (NS_FAILED(rv))
return rv;
MakeContextCurrent();
glDrawElements(mode, count, GL_UNSIGNED_SHORT, sbuffer.data);
return NS_OK;
}
GL_SAME_METHOD_1(Enable, Enable, PRUint32)
@ -1027,10 +1061,11 @@ nsCanvasRenderingContextGLWeb20::TexImage2DHTML(PRUint32 target, nsIDOMHTMLEleme
}
if (!image_data) {
nsRefPtr<gfxImageSurface> tmpImageSurface = new gfxImageSurface(gfxIntSize(width, height),
gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> cx = new gfxContext(tmpImageSurface);
nsRefPtr<gfxImageSurface> tmpImageSurface =
CanvasGLThebes::CreateImageSurface(gfxIntSize(width, height),
gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> cx =
CanvasGLThebes::CreateContext(tmpImageSurface);
cx->SetSource(surf);
cx->SetOperator(gfxContext::OPERATOR_SOURCE);
cx->Paint();
@ -1401,6 +1436,12 @@ nsCanvasRenderingContextGLWeb20::VertexAttribPointer()
return NS_ERROR_DOM_SYNTAX_ERR;
}
// if it's out of bounds, bail
if (vertexAttribIndex >= mAttribBuffers.Length())
return NS_ERROR_DOM_SYNTAX_ERR;
mAttribBuffers[vertexAttribIndex] = newBuffer;
MakeContextCurrent();
glVertexAttribPointer(vertexAttribIndex,
newBuffer->GetSimpleBuffer().sizePerVertex,
@ -1418,5 +1459,13 @@ nsCanvasRenderingContextGLWeb20::ValidateGL()
if (!GLEW_VERSION_2_0)
return PR_FALSE;
GLint val;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &val);
mAttribBuffers.SetLength(val);
MakeContextCurrent();
if (mPrefWireframe)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
return PR_TRUE;
}

Просмотреть файл

@ -46,13 +46,17 @@
void *nsGLPbuffer::sCurrentContextToken = nsnull;
static PRUint32 gActiveBuffers = 0;
nsGLPbuffer::nsGLPbuffer()
: mWidth(0), mHeight(0),
#ifdef XP_WIN
mGlewWindow(nsnull), mGlewDC(nsnull), mGlewWglContext(nsnull),
mPbufferDC(nsnull), mPbufferContext(nsnull)
mPbuffer(nsnull), mPbufferDC(nsnull), mPbufferContext(nsnull)
#endif
{
gActiveBuffers++;
fprintf (stderr, "nsGLPbuffer: gActiveBuffers: %d\n", gActiveBuffers);
}
PRBool
@ -116,11 +120,15 @@ nsGLPbuffer::Init(nsCanvasRenderingContextGLPrivate *priv)
return PR_FALSE;
}
PRInt64 t1 = PR_Now();
if (wglewInit() != GLEW_OK) {
mPriv->LogMessage(NS_LITERAL_CSTRING("Canvas 3D: WGLEW init failed"));
return PR_FALSE;
}
PRInt64 t2 = PR_Now();
fprintf (stderr, "nsGLPbuffer::Init!\n");
#else
return PR_FALSE;
@ -131,6 +139,12 @@ nsGLPbuffer::Init(nsCanvasRenderingContextGLPrivate *priv)
return PR_FALSE;
}
PRInt64 t3 = PR_Now();
fprintf (stderr, "nsGLPbuffer:: Initialization took t2-t1: %f t3-t2: %f\n",
((double)(t2-t1))/1000.0, ((double)(t3-t2))/1000.0);
fflush (stderr);
return PR_TRUE;
}
@ -145,6 +159,17 @@ nsGLPbuffer::Resize(PRInt32 width, PRInt32 height)
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());
#ifdef XP_WIN
if (!wglMakeCurrent(mGlewDC, mGlewWglContext)) {
fprintf (stderr, "Error: %d\n", GetLastError());
@ -257,21 +282,6 @@ nsGLPbuffer::Resize(PRInt32 width, PRInt32 height)
mPbufferDC = wglGetPbufferDCARB(mPbuffer);
mPbufferContext = wglCreateContext(mPbufferDC);
mThebesSurface = new gfxImageSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32);
#if 0
if (mThebesSurface->Status() != 0) {
fprintf (stderr, "image surface failed\n");
return PR_FALSE;
}
#endif
{
nsRefPtr<gfxContext> ctx = new gfxContext(mThebesSurface);
ctx->SetColor(gfxRGBA(0, 1, 0, 1));
ctx->Paint();
}
#endif
mWidth = width;
@ -304,6 +314,10 @@ nsGLPbuffer::~nsGLPbuffer()
mGlewWindow = nsnull;
}
#endif
gActiveBuffers--;
fprintf (stderr, "nsGLPbuffer: gActiveBuffers: %d\n", gActiveBuffers);
fflush (stderr);
}
void

Просмотреть файл

@ -76,6 +76,9 @@ public:
}
#endif
PRInt32 Width() { return mWidth; }
PRInt32 Height() { return mHeight; }
protected:
static void *sCurrentContextToken;