Bug 757347; checking the format of images. r=roc

This commit is contained in:
Nicholas Cameron 2012-06-26 14:43:31 +12:00
parent 65d2f251d1
commit 0e6b01bba2
4 changed files with 24 additions and 0 deletions

View File

@ -910,6 +910,9 @@ BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
return nsnull; return nsnull;
} }
NS_ASSERTION(surface->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
nsRefPtr<gfxPattern> pat = new gfxPattern(surface); nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
if (!pat) { if (!pat) {
return nsnull; return nsnull;

View File

@ -191,6 +191,10 @@ ImageLayerD3D10::RenderLayer()
if (image->GetFormat() == Image::CAIRO_SURFACE || image->GetFormat() == Image::REMOTE_IMAGE_BITMAP || if (image->GetFormat() == Image::CAIRO_SURFACE || image->GetFormat() == Image::REMOTE_IMAGE_BITMAP ||
image->GetFormat() == Image::REMOTE_IMAGE_DXGI_TEXTURE) image->GetFormat() == Image::REMOTE_IMAGE_DXGI_TEXTURE)
{ {
NS_ASSERTION(image->GetFormat() != Image::CAIRO_SURFACE ||
!static_cast<CairoImage*>(image)->mSurface ||
static_cast<CairoImage*>(image)->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
bool hasAlpha = false; bool hasAlpha = false;
nsRefPtr<ID3D10ShaderResourceView> srView = GetImageSRView(image, hasAlpha, getter_AddRefs(keyedMutex)); nsRefPtr<ID3D10ShaderResourceView> srView = GetImageSRView(image, hasAlpha, getter_AddRefs(keyedMutex));

View File

@ -372,6 +372,11 @@ ImageLayerD3D9::RenderLayer()
if (image->GetFormat() == Image::CAIRO_SURFACE || if (image->GetFormat() == Image::CAIRO_SURFACE ||
image->GetFormat() == Image::REMOTE_IMAGE_BITMAP) image->GetFormat() == Image::REMOTE_IMAGE_BITMAP)
{ {
NS_ASSERTION(image->GetFormat() != Image::CAIRO_SURFACE ||
!static_cast<CairoImage*>(image)->mSurface ||
static_cast<CairoImage*>(image)->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
bool hasAlpha = false; bool hasAlpha = false;
nsRefPtr<IDirect3DTexture9> texture = GetTexture(image, hasAlpha); nsRefPtr<IDirect3DTexture9> texture = GetTexture(image, hasAlpha);

View File

@ -271,6 +271,9 @@ ImageLayerOGL::RenderLayer(int,
return; return;
} }
NS_ASSERTION(cairoImage->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
CairoOGLBackendData *data = CairoOGLBackendData *data =
static_cast<CairoOGLBackendData*>(cairoImage->GetBackendData(LayerManager::LAYERS_OPENGL)); static_cast<CairoOGLBackendData*>(cairoImage->GetBackendData(LayerManager::LAYERS_OPENGL));
@ -594,6 +597,9 @@ ImageLayerOGL::LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize)
cairoImage->GetBackendData(LayerManager::LAYERS_OPENGL)); cairoImage->GetBackendData(LayerManager::LAYERS_OPENGL));
if (!data) { if (!data) {
NS_ASSERTION(cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_ALPHA,
"OpenGL mask layers must be backed by alpha surfaces");
// allocate a new texture and save the details in the backend data // allocate a new texture and save the details in the backend data
data = new CairoOGLBackendData; data = new CairoOGLBackendData;
data->mTextureSize = CalculatePOTSize(cairoImage->mSize, gl()); data->mTextureSize = CalculatePOTSize(cairoImage->mSize, gl());
@ -775,6 +781,9 @@ ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer,
mOGLManager->MakeCurrent(); mOGLManager->MakeCurrent();
if (mTexImage) { if (mTexImage) {
NS_ASSERTION(mTexImage->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
ShaderProgramOGL *colorProgram = ShaderProgramOGL *colorProgram =
mOGLManager->GetProgram(mTexImage->GetShaderProgramType(), GetMaskLayer()); mOGLManager->GetProgram(mTexImage->GetShaderProgramType(), GetMaskLayer());
@ -845,6 +854,9 @@ ShadowImageLayerOGL::LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize)
mTexImage->BindTextureAndApplyFilter(aTextureUnit); mTexImage->BindTextureAndApplyFilter(aTextureUnit);
NS_ASSERTION(mTexImage->GetContentType() == gfxASurface::CONTENT_ALPHA,
"OpenGL mask layers must be backed by alpha surfaces");
// We're assuming that the gl backend won't cheat and use NPOT // We're assuming that the gl backend won't cheat and use NPOT
// textures when glContext says it can't (which seems to happen // textures when glContext says it can't (which seems to happen
// on a mac when you force POT textures) // on a mac when you force POT textures)