Bug 987010 - Fix the way that the presence of an alpha channel on a canvas drawing buffer is propagated - r=jrmuizel

This commit is contained in:
Benoit Jacob
2014-05-14 12:26:13 -04:00
parent 67f8a5c10e
commit a7529cb0d2
4 changed files with 11 additions and 2 deletions

View File

@@ -4255,6 +4255,7 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
}
data.mSize = nsIntSize(mWidth, mHeight);
data.mHasAlpha = !mOpaque;
canvasLayer->Initialize(data);
uint32_t flags = mOpaque ? Layer::CONTENT_OPAQUE : 0;

View File

@@ -893,6 +893,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer::Data data;
data.mGLContext = gl;
data.mSize = nsIntSize(mWidth, mHeight);
data.mHasAlpha = gl->Caps().alpha;
data.mIsGLAlphaPremult = IsPremultAlpha();
canvasLayer->Initialize(data);

View File

@@ -1869,6 +1869,7 @@ public:
, mStream(nullptr)
, mTexID(0)
, mSize(0,0)
, mHasAlpha(false)
, mIsGLAlphaPremult(false)
{ }
@@ -1885,6 +1886,9 @@ public:
// The size of the canvas content
nsIntSize mSize;
// Whether the canvas drawingbuffer has an alpha channel.
bool mHasAlpha;
// Whether mGLContext contains data that is alpha-premultiplied.
bool mIsGLAlphaPremult;
};

View File

@@ -55,11 +55,14 @@ ClientCanvasLayer::Initialize(const Data& aData)
if (mGLContext) {
GLScreenBuffer* screen = mGLContext->Screen();
SurfaceCaps caps = screen->Caps();
SurfaceCaps caps;
if (mStream) {
// The screen caps are irrelevant if we're using a separate stream
caps = GetContentFlags() & CONTENT_OPAQUE ? SurfaceCaps::ForRGB() : SurfaceCaps::ForRGBA();
caps = aData.mHasAlpha ? SurfaceCaps::ForRGBA() : SurfaceCaps::ForRGB();
} else {
caps = screen->Caps();
}
MOZ_ASSERT(caps.alpha == aData.mHasAlpha);
SurfaceStreamType streamType =
SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,