Bug 716439; using mask layers in OGL. r=BenWa

This commit is contained in:
Nicholas Cameron 2012-03-19 09:08:53 +13:00
Родитель a82db9af35
Коммит a6780c7a3a
4 изменённых файлов: 30 добавлений и 7 удалений

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

@ -249,7 +249,9 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
if (useGLContext) { if (useGLContext) {
gl()->BindTex2DOffscreen(mCanvasGLContext); gl()->BindTex2DOffscreen(mCanvasGLContext);
program = mOGLManager->GetBasicLayerProgram(CanUseOpaqueSurface(), true); program = mOGLManager->GetBasicLayerProgram(CanUseOpaqueSurface(),
true,
GetMaskLayer() ? Mask2d : MaskNone);
} else if (mDelayedUpdates) { } else if (mDelayedUpdates) {
NS_ABORT_IF_FALSE(mCanvasSurface || mDrawTarget, "WebGL canvases should always be using full texture upload"); NS_ABORT_IF_FALSE(mCanvasSurface || mDrawTarget, "WebGL canvases should always be using full texture upload");
@ -269,7 +271,7 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
} }
if (!program) { if (!program) {
program = mOGLManager->GetProgram(mLayerProgram); program = mOGLManager->GetProgram(mLayerProgram, GetMaskLayer());
} }
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO) #if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
@ -286,6 +288,7 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
program->SetLayerOpacity(GetEffectiveOpacity()); program->SetLayerOpacity(GetEffectiveOpacity());
program->SetRenderOffset(aOffset); program->SetRenderOffset(aOffset);
program->SetTextureUnit(0); program->SetTextureUnit(0);
program->LoadMask(GetMaskLayer());
if (gl()->CanUploadNonPowerOfTwo()) { if (gl()->CanUploadNonPowerOfTwo()) {
mOGLManager->BindAndDrawQuad(program, mNeedsYFlip ? true : false); mOGLManager->BindAndDrawQuad(program, mNeedsYFlip ? true : false);
@ -394,6 +397,7 @@ ShadowCanvasLayerOGL::RenderLayer(int aPreviousFrameBuffer,
{ {
mOGLManager->MakeCurrent(); mOGLManager->MakeCurrent();
//TODO[nrc] shadow layer masking?
ShaderProgramOGL *program = ShaderProgramOGL *program =
mOGLManager->GetProgram(mTexImage->GetShaderProgramType()); mOGLManager->GetProgram(mTexImage->GetShaderProgramType());

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

@ -63,12 +63,14 @@ RenderColorLayer(ColorLayer* aLayer, LayerManagerOGL *aManager,
color.b *= opacity; color.b *= opacity;
color.a = opacity; color.a = opacity;
ShaderProgramOGL *program = aManager->GetProgram(gl::ColorLayerProgramType); ShaderProgramOGL *program = aManager->GetProgram(gl::ColorLayerProgramType,
aLayer->GetMaskLayer());
program->Activate(); program->Activate();
program->SetLayerQuadRect(visibleRect); program->SetLayerQuadRect(visibleRect);
program->SetLayerTransform(aLayer->GetEffectiveTransform()); program->SetLayerTransform(aLayer->GetEffectiveTransform());
program->SetRenderOffset(aOffset); program->SetRenderOffset(aOffset);
program->SetRenderColor(color); program->SetRenderColor(color);
program->LoadMask(aLayer->GetMaskLayer());
aManager->BindAndDrawQuad(program); aManager->BindAndDrawQuad(program);
} }

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

@ -279,7 +279,16 @@ ContainerRender(Container* aContainer,
aContainer->gl()->fBindTexture(aManager->FBOTextureTarget(), containerSurface); aContainer->gl()->fBindTexture(aManager->FBOTextureTarget(), containerSurface);
ShaderProgramOGL *rgb = aManager->GetFBOLayerProgram(); MaskType maskType = MaskNone;
if (aContainer->GetMaskLayer()) {
if (!aContainer->GetTransform().CanDraw2D()) {
maskType = Mask3d;
} else {
maskType = Mask2d;
}
}
ShaderProgramOGL *rgb =
aManager->GetFBOLayerProgram(maskType);
rgb->Activate(); rgb->Activate();
rgb->SetLayerQuadRect(visibleRect); rgb->SetLayerQuadRect(visibleRect);
@ -287,6 +296,7 @@ ContainerRender(Container* aContainer,
rgb->SetLayerOpacity(opacity); rgb->SetLayerOpacity(opacity);
rgb->SetRenderOffset(aOffset); rgb->SetRenderOffset(aOffset);
rgb->SetTextureUnit(0); rgb->SetTextureUnit(0);
rgb->LoadMask(aContainer->GetMaskLayer());
if (rgb->GetTexCoordMultiplierUniformLocation() != -1) { if (rgb->GetTexCoordMultiplierUniformLocation() != -1) {
// 2DRect case, get the multiplier right for a sampler2DRect // 2DRect case, get the multiplier right for a sampler2DRect

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

@ -275,7 +275,8 @@ ImageLayerOGL::RenderLayer(int,
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, data->mTextures[0].GetTextureID()); gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, data->mTextures[0].GetTextureID());
gl()->ApplyFilterToBoundTexture(mFilter); gl()->ApplyFilterToBoundTexture(mFilter);
ShaderProgramOGL *program = mOGLManager->GetProgram(YCbCrLayerProgramType); ShaderProgramOGL *program = mOGLManager->GetProgram(YCbCrLayerProgramType,
GetMaskLayer());
program->Activate(); program->Activate();
program->SetLayerQuadRect(nsIntRect(0, 0, program->SetLayerQuadRect(nsIntRect(0, 0,
@ -285,6 +286,7 @@ ImageLayerOGL::RenderLayer(int,
program->SetLayerOpacity(GetEffectiveOpacity()); program->SetLayerOpacity(GetEffectiveOpacity());
program->SetRenderOffset(aOffset); program->SetRenderOffset(aOffset);
program->SetYCbCrTextureUnits(0, 1, 2); program->SetYCbCrTextureUnits(0, 1, 2);
program->LoadMask(GetMaskLayer());
mOGLManager->BindAndDrawQuadWithTextureRect(program, mOGLManager->BindAndDrawQuadWithTextureRect(program,
yuvImage->mData.GetPictureRect(), yuvImage->mData.GetPictureRect(),
@ -342,7 +344,7 @@ ImageLayerOGL::RenderLayer(int,
#endif #endif
ShaderProgramOGL *program = ShaderProgramOGL *program =
mOGLManager->GetProgram(data->mLayerProgram); mOGLManager->GetProgram(data->mLayerProgram, GetMaskLayer());
gl()->ApplyFilterToBoundTexture(mFilter); gl()->ApplyFilterToBoundTexture(mFilter);
@ -355,6 +357,7 @@ ImageLayerOGL::RenderLayer(int,
program->SetLayerOpacity(GetEffectiveOpacity()); program->SetLayerOpacity(GetEffectiveOpacity());
program->SetRenderOffset(aOffset); program->SetRenderOffset(aOffset);
program->SetTextureUnit(0); program->SetTextureUnit(0);
program->LoadMask(GetMaskLayer());
nsIntRect rect = GetVisibleRegion().GetBounds(); nsIntRect rect = GetVisibleRegion().GetBounds();
@ -430,7 +433,8 @@ ImageLayerOGL::RenderLayer(int,
gl()->fActiveTexture(LOCAL_GL_TEXTURE0); gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, data->mTexture.GetTextureID()); gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, data->mTexture.GetTextureID());
ShaderProgramOGL *program = mOGLManager->GetProgram(gl::RGBARectLayerProgramType); ShaderProgramOGL *program =
mOGLManager->GetProgram(gl::RGBARectLayerProgramType, GetMaskLayer());
program->Activate(); program->Activate();
if (program->GetTexCoordMultiplierUniformLocation() != -1) { if (program->GetTexCoordMultiplierUniformLocation() != -1) {
@ -447,6 +451,7 @@ ImageLayerOGL::RenderLayer(int,
program->SetLayerOpacity(GetEffectiveOpacity()); program->SetLayerOpacity(GetEffectiveOpacity());
program->SetRenderOffset(aOffset); program->SetRenderOffset(aOffset);
program->SetTextureUnit(0); program->SetTextureUnit(0);
program->LoadMask(GetMaskLayer());
mOGLManager->BindAndDrawQuad(program); mOGLManager->BindAndDrawQuad(program);
gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0); gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
@ -800,6 +805,7 @@ ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer,
mOGLManager->MakeCurrent(); mOGLManager->MakeCurrent();
if (mTexImage) { if (mTexImage) {
//TODO[nrc] shadow layer masking?
ShaderProgramOGL *colorProgram = ShaderProgramOGL *colorProgram =
mOGLManager->GetProgram(mTexImage->GetShaderProgramType()); mOGLManager->GetProgram(mTexImage->GetShaderProgramType());
@ -842,6 +848,7 @@ ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer,
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[2].GetTextureID()); gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[2].GetTextureID());
gl()->ApplyFilterToBoundTexture(mFilter); gl()->ApplyFilterToBoundTexture(mFilter);
//TODO[nrc] shadow layer masking?
ShaderProgramOGL *yuvProgram = mOGLManager->GetProgram(YCbCrLayerProgramType); ShaderProgramOGL *yuvProgram = mOGLManager->GetProgram(YCbCrLayerProgramType);
yuvProgram->Activate(); yuvProgram->Activate();