b=571027; implement new PixelStorei parameters for textures; r=vladimir

This commit is contained in:
Benoit Jacob 2010-06-15 11:59:39 -04:00
parent 3e15743355
commit db543d277d
4 changed files with 38 additions and 11 deletions

View File

@ -78,7 +78,9 @@ WebGLContext::WebGLContext()
mGeneration(0),
mInvalidated(PR_FALSE),
mActiveTexture(0),
mSynthesizedGLError(LOCAL_GL_NO_ERROR)
mSynthesizedGLError(LOCAL_GL_NO_ERROR),
mPixelStoreFlipY(PR_FALSE),
mPixelStorePremultiplyAlpha(PR_FALSE)
{
mMapBuffers.Init();
mMapTextures.Init();

View File

@ -60,6 +60,10 @@
#include "GLContext.h"
#include "Layers.h"
#define UNPACK_FLIP_Y_WEBGL 0x9240
#define UNPACK_PREMULTIPLY_ALPHA_WEBGL 0x9241
#define CONTEXT_LOST_WEBGL 0x9242
class nsIDocShell;
namespace mozilla {
@ -383,6 +387,9 @@ protected:
nsRefPtrHashtable<nsUint32HashKey, WebGLFramebuffer> mMapFramebuffers;
nsRefPtrHashtable<nsUint32HashKey, WebGLRenderbuffer> mMapRenderbuffers;
// WebGL-specific PixelStore parameters
PRBool mPixelStoreFlipY, mPixelStorePremultiplyAlpha;
public:
// console logging helpers
static void LogMessage (const char *fmt, ...);

View File

@ -1233,6 +1233,7 @@ WebGLContext::GetParameter(PRUint32 pname, nsIVariant **retval)
case LOCAL_GL_ALPHA_BITS:
case LOCAL_GL_DEPTH_BITS:
case LOCAL_GL_STENCIL_BITS:
case LOCAL_GL_PACK_ALIGNMENT:
//case LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE:
//case LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT:
{
@ -2027,20 +2028,33 @@ WebGLContext::LinkProgram(nsIWebGLProgram *pobj)
return NS_OK;
}
// XXX #if 0
NS_IMETHODIMP
WebGLContext::PixelStorei(WebGLenum pname, WebGLint param)
{
if (pname != LOCAL_GL_PACK_ALIGNMENT &&
pname != LOCAL_GL_UNPACK_ALIGNMENT)
return ErrorInvalidEnum("PixelStorei: invalid parameter");
MakeContextCurrent();
gl->fPixelStorei(pname, param);
switch (pname) {
case UNPACK_FLIP_Y_WEBGL:
mPixelStoreFlipY = (param != 0);
break;
case UNPACK_PREMULTIPLY_ALPHA_WEBGL:
mPixelStorePremultiplyAlpha = (param != 0);
break;
case LOCAL_GL_PACK_ALIGNMENT:
case LOCAL_GL_UNPACK_ALIGNMENT:
if (param != 1 &&
param != 2 &&
param != 4 &&
param != 8)
return ErrorInvalidValue("PixelStorei: invalid pack/unpack alignment value");
MakeContextCurrent();
gl->fPixelStorei(pname, param);
break;
default:
return ErrorInvalidEnum("PixelStorei: invalid parameter");
}
return NS_OK;
}
//#endif
GL_SAME_METHOD_2(PolygonOffset, PolygonOffset, float, float)
@ -2812,7 +2826,7 @@ WebGLContext::TexImage2D_dom(WebGLenum target, WebGLint level, WebGLenum interna
nsRefPtr<gfxImageSurface> isurf;
nsresult rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf),
PR_FALSE/*flipY*/, PR_FALSE/*premultiplyAlpha*/);
mPixelStoreFlipY, mPixelStorePremultiplyAlpha);
if (NS_FAILED(rv))
return rv;
@ -2986,7 +3000,7 @@ WebGLContext::TexSubImage2D_dom(WebGLenum target, WebGLint level,
nsRefPtr<gfxImageSurface> isurf;
nsresult rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf),
PR_FALSE/*flipY*/, PR_FALSE/*premultiplyAlpha*/);
mPixelStoreFlipY, mPixelStorePremultiplyAlpha);
if (NS_FAILED(rv))
return rv;

View File

@ -567,6 +567,10 @@ interface nsICanvasRenderingContextWebGL : nsISupports
const unsigned long INVALID_FRAMEBUFFER_OPERATION = 0x0506;
const unsigned long UNPACK_FLIP_Y_WEBGL = 0x9240;
const unsigned long UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
const unsigned long CONTEXT_LOST_WEBGL = 0x9242;
//
// ATTRIBUTES
//