Backed out changeset f24ee0606ea6 (bug 926128) for reftest failures on OS X & crashes on B2G on a CLOSED TREE

This commit is contained in:
Ed Morley 2013-11-01 15:51:32 +00:00
parent 1a1e9c73c3
commit 2153b816b9
24 changed files with 541 additions and 854 deletions

View File

@ -121,7 +121,10 @@ enum EffectTypes
{
EFFECT_MASK,
EFFECT_MAX_SECONDARY, // sentinel for the count of secondary effect types
EFFECT_RGB,
EFFECT_BGRX,
EFFECT_RGBX,
EFFECT_BGRA,
EFFECT_RGBA,
EFFECT_YCBCR,
EFFECT_COMPONENT_ALPHA,
EFFECT_SOLID_COLOR,

View File

@ -113,17 +113,56 @@ struct EffectRenderTarget : public TexturedEffect
RefPtr<CompositingRenderTarget> mRenderTarget;
};
struct EffectRGB : public TexturedEffect
struct EffectBGRX : public TexturedEffect
{
EffectRGB(TextureSource *aTexture,
bool aPremultiplied,
gfx::Filter aFilter,
bool aFlipped = false)
: TexturedEffect(EFFECT_RGB, aTexture, aPremultiplied, aFilter)
EffectBGRX(TextureSource *aBGRXTexture,
bool aPremultiplied,
gfx::Filter aFilter,
bool aFlipped = false)
: TexturedEffect(EFFECT_BGRX, aBGRXTexture, aPremultiplied, aFilter)
{}
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() { return "EffectRGB"; }
virtual const char* Name() { return "EffectBGRX"; }
#endif
};
struct EffectRGBX : public TexturedEffect
{
EffectRGBX(TextureSource *aRGBXTexture,
bool aPremultiplied,
gfx::Filter aFilter)
: TexturedEffect(EFFECT_RGBX, aRGBXTexture, aPremultiplied, aFilter)
{}
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() { return "EffectRGBX"; }
#endif
};
struct EffectBGRA : public TexturedEffect
{
EffectBGRA(TextureSource *aBGRATexture,
bool aPremultiplied,
gfx::Filter aFilter)
: TexturedEffect(EFFECT_BGRA, aBGRATexture, aPremultiplied, aFilter)
{}
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() { return "EffectBGRA"; }
#endif
};
struct EffectRGBA : public TexturedEffect
{
EffectRGBA(TextureSource *aRGBATexture,
bool aPremultiplied,
gfx::Filter aFilter)
: TexturedEffect(EFFECT_RGBA, aRGBATexture, aPremultiplied, aFilter)
{}
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() { return "EffectRGBA"; }
#endif
};
@ -193,12 +232,20 @@ CreateTexturedEffect(gfx::SurfaceFormat aFormat,
MOZ_ASSERT(aSource);
RefPtr<TexturedEffect> result;
switch (aFormat) {
case gfx::FORMAT_R8G8B8A8:
case gfx::FORMAT_R8G8B8X8:
case gfx::FORMAT_B8G8R8A8:
result = new EffectBGRA(aSource, true, aFilter);
break;
case gfx::FORMAT_B8G8R8X8:
result = new EffectBGRX(aSource, true, aFilter);
break;
case gfx::FORMAT_R8G8B8X8:
result = new EffectRGBX(aSource, true, aFilter);
break;
case gfx::FORMAT_R5G6B5:
result = new EffectRGB(aSource, true, aFilter);
result = new EffectRGBX(aSource, true, aFilter);
break;
case gfx::FORMAT_R8G8B8A8:
result = new EffectRGBA(aSource, true, aFilter);
break;
case gfx::FORMAT_YUV:
result = new EffectYCbCr(aSource, aFilter);

View File

@ -370,7 +370,10 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect, const gfx::Rect& aClipRect,
DrawOptions(aOpacity));
break;
}
case EFFECT_RGB: {
case EFFECT_BGRA:
case EFFECT_BGRX:
case EFFECT_RGBA:
case EFFECT_RGBX: {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
TextureSourceBasic* source = texturedEffect->mTexture->AsSourceBasic();

View File

@ -450,19 +450,18 @@ CompositorD3D11::SetRenderTarget(CompositingRenderTarget* aRenderTarget)
}
void
CompositorD3D11::SetPSForEffect(Effect* aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat)
CompositorD3D11::SetPSForEffect(Effect* aEffect, MaskType aMaskType)
{
switch (aEffect->mType) {
case EFFECT_SOLID_COLOR:
mContext->PSSetShader(mAttachments->mSolidColorShader[aMaskType], nullptr, 0);
return;
case EFFECT_BGRA:
case EFFECT_RENDER_TARGET:
mContext->PSSetShader(mAttachments->mRGBAShader[aMaskType], nullptr, 0);
return;
case EFFECT_RGB:
mContext->PSSetShader((aFormat == FORMAT_B8G8R8A8 || aFormat == FORMAT_R8G8B8A8)
? mAttachments->mRGBAShader[aMaskType]
: mAttachments->mRGBShader[aMaskType], nullptr, 0);
case EFFECT_BGRX:
mContext->PSSetShader(mAttachments->mRGBShader[aMaskType], nullptr, 0);
return;
case EFFECT_YCBCR:
mContext->PSSetShader(mAttachments->mYCbCrShader[aMaskType], nullptr, 0);
@ -500,7 +499,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
if (aTransform.Is2D()) {
maskType = Mask2d;
} else {
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EFFECT_RGB);
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EFFECT_BGRA);
maskType = Mask3d;
}
@ -531,9 +530,10 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
mContext->VSSetShader(mAttachments->mVSQuadShader[maskType], nullptr, 0);
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType);
switch (aEffectChain.mPrimaryEffect->mType) {
case EFFECT_SOLID_COLOR: {
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, FORMAT_UNKNOWN);
Color color =
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get())->mColor;
mPSConstants.layerColor[0] = color.r * color.a * aOpacity;
@ -542,14 +542,13 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
mPSConstants.layerColor[3] = color.a * aOpacity;
}
break;
case EFFECT_RGB:
case EFFECT_BGRX:
case EFFECT_BGRA:
case EFFECT_RENDER_TARGET:
{
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, texturedEffect->mTexture->GetFormat());
mVSConstants.textureCoords = texturedEffect->mTextureCoords;
TextureSourceD3D11* source = texturedEffect->mTexture->AsSourceD3D11();
@ -572,8 +571,6 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
EffectYCbCr* ycbcrEffect =
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, ycbcrEffect->mTexture->GetFormat());
SetSamplerForFilter(FILTER_LINEAR);
mVSConstants.textureCoords = ycbcrEffect->mTextureCoords;
@ -596,9 +593,6 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
MOZ_ASSERT(mAttachments->mComponentBlendState);
EffectComponentAlpha* effectComponentAlpha =
static_cast<EffectComponentAlpha*>(aEffectChain.mPrimaryEffect.get());
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, effectComponentAlpha->mTexture->GetFormat());
TextureSourceD3D11* sourceOnWhite = effectComponentAlpha->mOnWhite->AsSourceD3D11();
TextureSourceD3D11* sourceOnBlack = effectComponentAlpha->mOnBlack->AsSourceD3D11();
SetSamplerForFilter(effectComponentAlpha->mFilter);

View File

@ -157,7 +157,7 @@ private:
bool CreateShaders();
void UpdateConstantBuffers();
void SetSamplerForFilter(gfx::Filter aFilter);
void SetPSForEffect(Effect *aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat);
void SetPSForEffect(Effect *aEffect, MaskType aMaskType);
void PaintToTarget();
RefPtr<ID3D11DeviceContext> mContext;

View File

@ -172,16 +172,15 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget)
}
static DeviceManagerD3D9::ShaderMode
ShaderModeForEffectType(EffectTypes aEffectType, gfx::SurfaceFormat aFormat)
ShaderModeForEffectType(EffectTypes aEffectType)
{
switch (aEffectType) {
case EFFECT_SOLID_COLOR:
return DeviceManagerD3D9::SOLIDCOLORLAYER;
case EFFECT_BGRA:
case EFFECT_RENDER_TARGET:
return DeviceManagerD3D9::RGBALAYER;
case EFFECT_RGB:
if (aFormat == FORMAT_B8G8R8A8 || aFormat == FORMAT_R8G8B8A8)
return DeviceManagerD3D9::RGBALAYER;
case EFFECT_BGRX:
return DeviceManagerD3D9::RGBLAYER;
case EFFECT_YCBCR:
return DeviceManagerD3D9::YCBCRLAYER;
@ -260,7 +259,8 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect, const gfx::Rect &aClipRect,
}
break;
case EFFECT_RENDER_TARGET:
case EFFECT_RGB:
case EFFECT_BGRX:
case EFFECT_BGRA:
{
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
@ -280,8 +280,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect, const gfx::Rect &aClipRect,
device()->SetTexture(0, source->GetD3D9Texture());
maskTexture = mDeviceManager
->SetShaderMode(ShaderModeForEffectType(aEffectChain.mPrimaryEffect->mType,
texturedEffect->mTexture->GetFormat()),
->SetShaderMode(ShaderModeForEffectType(aEffectChain.mPrimaryEffect->mType),
maskType);
isPremultiplied = texturedEffect->mPremultiplied;

View File

@ -347,7 +347,6 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
gl()->ApplyFilterToBoundTexture(mFilter);
program->Activate();
program->SetProjectionMatrix(mOGLManager->mProjMatrix);
if (mLayerProgram == RGBARectLayerProgramType ||
mLayerProgram == RGBXRectLayerProgramType) {
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.

View File

@ -40,7 +40,6 @@ RenderColorLayer(ColorLayer* aLayer, LayerManagerOGL *aManager,
ShaderProgramOGL *program = aManager->GetProgram(ColorLayerProgramType,
aLayer->GetMaskLayer());
program->Activate();
program->SetProjectionMatrix(aManager->mProjMatrix);
program->SetLayerQuadRect(aLayer->GetBounds());
program->SetLayerTransform(aLayer->GetEffectiveTransform());
program->SetRenderOffset(aOffset);

View File

@ -39,7 +39,6 @@
#include "nsRect.h" // for nsIntRect
#include "nsServiceManagerUtils.h" // for do_GetService
#include "nsString.h" // for nsString, nsAutoCString, etc
#include "LayerManagerOGLShaders.h" // for shader programs
#if MOZ_ANDROID_OMTC
#include "TexturePoolOGL.h"
@ -55,88 +54,6 @@ namespace layers {
using namespace mozilla::gl;
enum ShaderFeatures {
ENABLE_RENDER_COLOR=0x01,
ENABLE_TEXTURE_RECT=0x02,
ENABLE_TEXTURE_EXTERNAL=0x04,
ENABLE_TEXTURE_YCBCR=0x08,
ENABLE_TEXTURE_COMPONENT_ALPHA=0x10,
ENABLE_TEXTURE_NO_ALPHA=0x20,
ENABLE_TEXTURE_RB_SWAP=0x40,
ENABLE_OPACITY=0x80,
ENABLE_BLUR=0x100,
ENABLE_COLOR_MATRIX=0x200,
ENABLE_MASK=0x400
};
void
ShaderConfigOGL::SetRenderColor(bool aEnabled)
{
SetFeature(ENABLE_RENDER_COLOR, aEnabled);
}
void
ShaderConfigOGL::SetTextureTarget(GLenum aTarget)
{
SetFeature(ENABLE_TEXTURE_EXTERNAL | ENABLE_TEXTURE_RECT, false);
switch (aTarget) {
case LOCAL_GL_TEXTURE_EXTERNAL:
SetFeature(ENABLE_TEXTURE_EXTERNAL, true);
break;
case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
SetFeature(ENABLE_TEXTURE_RECT, true);
break;
}
}
void
ShaderConfigOGL::SetRBSwap(bool aEnabled)
{
SetFeature(ENABLE_TEXTURE_RB_SWAP, aEnabled);
}
void
ShaderConfigOGL::SetNoAlpha(bool aEnabled)
{
SetFeature(ENABLE_TEXTURE_NO_ALPHA, aEnabled);
}
void
ShaderConfigOGL::SetOpacity(bool aEnabled)
{
SetFeature(ENABLE_OPACITY, aEnabled);
}
void
ShaderConfigOGL::SetYCbCr(bool aEnabled)
{
SetFeature(ENABLE_TEXTURE_YCBCR, aEnabled);
}
void
ShaderConfigOGL::SetComponentAlpha(bool aEnabled)
{
SetFeature(ENABLE_TEXTURE_COMPONENT_ALPHA, aEnabled);
}
void
ShaderConfigOGL::SetColorMatrix(bool aEnabled)
{
SetFeature(ENABLE_COLOR_MATRIX, aEnabled);
}
void
ShaderConfigOGL::SetBlur(bool aEnabled)
{
SetFeature(ENABLE_BLUR, aEnabled);
}
void
ShaderConfigOGL::SetMask(bool aEnabled)
{
SetFeature(ENABLE_MASK, aEnabled);
}
static inline IntSize ns2gfxSize(const nsIntSize& s) {
return IntSize(s.width, s.height);
}
@ -240,14 +157,17 @@ AddDigits(GLContext::RectTriangles &aRects,
}
void
CompositorOGL::DrawFPS()
FPSState::DrawFPS(TimeStamp aNow,
unsigned int aFillRatio,
GLContext* aContext,
ShaderProgramOGL* aProgram)
{
if (!mFPSTexture) {
if (!mTexture) {
// Bind the number of textures we need, in this case one.
mGLContext->fGenTextures(1, &mFPSTexture);
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mFPSTexture);
mGLContext->fTexParameteri(LOCAL_GL_TEXTURE_2D,LOCAL_GL_TEXTURE_MIN_FILTER,LOCAL_GL_NEAREST);
mGLContext->fTexParameteri(LOCAL_GL_TEXTURE_2D,LOCAL_GL_TEXTURE_MAG_FILTER,LOCAL_GL_NEAREST);
aContext->fGenTextures(1, &mTexture);
aContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
aContext->fTexParameteri(LOCAL_GL_TEXTURE_2D,LOCAL_GL_TEXTURE_MIN_FILTER,LOCAL_GL_NEAREST);
aContext->fTexParameteri(LOCAL_GL_TEXTURE_2D,LOCAL_GL_TEXTURE_MAG_FILTER,LOCAL_GL_NEAREST);
const char *text =
" "
@ -267,54 +187,43 @@ CompositorOGL::DrawFPS()
buf[i * 64 + j] = (text[i * 41 + j] == ' ') ? purple : white;
}
}
mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, 64, 8, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, buf);
aContext->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, 64, 8, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, buf);
free(buf);
}
TimeStamp now = TimeStamp::Now();
unsigned int fps = unsigned(mFPS->mCompositionFps.AddFrameAndGetFps(now));
unsigned int txnFps = unsigned(mFPS->mTransactionFps.GetFpsAt(now));
float fillRatio = 0;
if (mPixelsFilled > 0 && mPixelsPerFrame > 0) {
fillRatio = 100.0f * float(mPixelsFilled) / float(mPixelsPerFrame);
if (fillRatio > 999.0f)
fillRatio = 999.0f;
}
mVBOs.Reset();
GLint viewport[4];
mGLContext->fGetIntegerv(LOCAL_GL_VIEWPORT, viewport);
aContext->fGetIntegerv(LOCAL_GL_VIEWPORT, viewport);
gfx::IntSize viewportSize(viewport[2], viewport[3]);
unsigned int fps = unsigned(mCompositionFps.AddFrameAndGetFps(aNow));
unsigned int txnFps = unsigned(mTransactionFps.GetFpsAt(aNow));
GLContext::RectTriangles rects;
AddDigits(rects, viewportSize, 0, fps);
AddDigits(rects, viewportSize, 4, txnFps);
AddDigits(rects, viewportSize, 8, unsigned(fillRatio));
AddDigits(rects, viewportSize, 8, aFillRatio);
// Turn necessary features on
mGLContext->fEnable(LOCAL_GL_BLEND);
mGLContext->fBlendFunc(LOCAL_GL_ONE, LOCAL_GL_SRC_COLOR);
aContext->fEnable(LOCAL_GL_BLEND);
aContext->fBlendFunc(LOCAL_GL_ONE, LOCAL_GL_SRC_COLOR);
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mFPSTexture);
aContext->fActiveTexture(LOCAL_GL_TEXTURE0);
aContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
ShaderConfigOGL config = GetShaderConfigFor(LOCAL_GL_TEXTURE_2D,
gfx::SurfaceFormat::FORMAT_R8G8B8X8);
ShaderProgramOGL *program = GetShaderProgramFor(config);
aProgram->Activate();
aProgram->SetTextureUnit(0);
aProgram->SetLayerQuadRect(gfx::Rect(0.f, 0.f, viewport[2], viewport[3]));
aProgram->SetLayerOpacity(1.f);
aProgram->SetTextureTransform(gfx3DMatrix());
aProgram->SetLayerTransform(gfx3DMatrix());
aProgram->SetRenderOffset(0, 0);
program->Activate();
program->SetProjectionMatrix(mProjMatrix);
program->SetTextureUnit(0);
program->SetLayerQuadRect(gfx::Rect(0.f, 0.f, viewport[2], viewport[3]));
program->SetTextureTransform(gfx3DMatrix());
program->SetLayerTransform(gfx3DMatrix());
program->SetRenderOffset(0, 0);
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ZERO,
aContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ZERO,
LOCAL_GL_ONE, LOCAL_GL_ZERO);
DrawQuads(mGLContext, mVBOs, program, rects);
DrawQuads(aContext, mVBOs, aProgram, rects);
}
#ifdef CHECK_CURRENT_PROGRAM
@ -329,7 +238,6 @@ CompositorOGL::CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth,
, mHasBGRA(0)
, mUseExternalSurfaceSize(aUseExternalSurfaceSize)
, mFrameInProgress(false)
, mFPSTexture(0)
, mDestroyed(false)
{
MOZ_COUNT_CTOR(CompositorOGL);
@ -363,6 +271,19 @@ CompositorOGL::CreateContext()
return context.forget();
}
void
CompositorOGL::AddPrograms(ShaderProgramType aType)
{
for (uint32_t maskType = MaskNone; maskType < NumMaskTypes; ++maskType) {
if (ProgramProfileOGL::ProgramExists(aType, static_cast<MaskType>(maskType))) {
mPrograms[aType].mVariations[maskType] = new ShaderProgramOGL(this->gl(),
ProgramProfileOGL::GetProfileFor(aType, static_cast<MaskType>(maskType)));
} else {
mPrograms[aType].mVariations[maskType] = nullptr;
}
}
}
GLuint
CompositorOGL::GetTemporaryTexture(GLenum aTextureUnit)
{
@ -393,8 +314,9 @@ CompositorOGL::Destroy()
}
mVBOs.Flush(gl());
if (mFPS) {
if (mFPSTexture > 0)
gl()->fDeleteTextures(1, &mFPSTexture);
if (mFPS->mTexture > 0)
gl()->fDeleteTextures(1, &mFPS->mTexture);
mFPS->mVBOs.Flush(gl());
}
}
mTextures.SetLength(0);
@ -415,7 +337,7 @@ CompositorOGL::CleanupResources()
ctx = mGLContext;
}
mPrograms.clear();
mPrograms.Clear();
ctx->MakeCurrent();
@ -468,10 +390,13 @@ CompositorOGL::Initialize()
LOCAL_GL_ONE, LOCAL_GL_ONE);
mGLContext->fEnable(LOCAL_GL_BLEND);
mPrograms.AppendElements(NumProgramTypes);
for (int type = 0; type < NumProgramTypes; ++type) {
AddPrograms(static_cast<ShaderProgramType>(type));
}
// initialise a common shader to check that we can actually compile a shader
RefPtr<EffectSolidColor> effect = new EffectSolidColor(Color(0, 0, 0, 0));
ShaderConfigOGL config = GetShaderConfigFor(effect);
if (!GetShaderProgramFor(config)) {
if (!mPrograms[RGBALayerProgramType].mVariations[MaskNone]->Initialize()) {
return false;
}
@ -714,7 +639,19 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
matrix3d._33 = 0.0f;
mProjMatrix = matrix3d;
SetLayerProgramProjectionMatrix(matrix3d);
}
void
CompositorOGL::SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix)
{
for (unsigned int i = 0; i < mPrograms.Length(); ++i) {
for (uint32_t mask = MaskNone; mask < NumMaskTypes; ++mask) {
if (mPrograms[i].mVariations[mask]) {
mPrograms[i].mVariations[mask]->CheckAndSetProjectionMatrix(aMatrix);
}
}
}
}
TemporaryRef<CompositingRenderTarget>
@ -993,126 +930,31 @@ CompositorOGL::CreateFBOWithTexture(const IntRect& aRect, SurfaceInitMode aInit,
*aTexture = tex;
}
ShaderConfigOGL
CompositorOGL::GetShaderConfigFor(Effect *aEffect, MaskType aMask) const
ShaderProgramType
CompositorOGL::GetProgramTypeForEffect(Effect *aEffect) const
{
ShaderConfigOGL config;
switch(aEffect->mType) {
case EFFECT_SOLID_COLOR:
config.SetRenderColor(true);
break;
case EFFECT_YCBCR:
config.SetYCbCr(true);
break;
case EFFECT_COMPONENT_ALPHA:
config.SetComponentAlpha(true);
break;
case EFFECT_RENDER_TARGET:
config.SetTextureTarget(mFBOTextureTarget);
break;
default:
return ColorLayerProgramType;
case EFFECT_RGBA:
case EFFECT_RGBX:
case EFFECT_BGRA:
case EFFECT_BGRX:
{
MOZ_ASSERT(aEffect->mType == EFFECT_RGB);
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffect);
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_EXTERNAL,
source->GetFormat() == gfx::FORMAT_R8G8B8A8);
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB,
source->GetFormat() == gfx::FORMAT_R8G8B8A8 ||
source->GetFormat() == gfx::FORMAT_R8G8B8X8 ||
source->GetFormat() == gfx::FORMAT_R5G6B5);
config = GetShaderConfigFor(source->GetTextureTarget(),
source->GetFormat());
break;
return ShaderProgramFromTargetAndFormat(source->GetTextureTarget(),
source->GetFormat());
}
case EFFECT_YCBCR:
return YCbCrLayerProgramType;
case EFFECT_RENDER_TARGET:
return GetFBOLayerProgramType();
default:
return RGBALayerProgramType;
}
config.SetMask(aMask != MaskNone);
return config;
}
ShaderConfigOGL
CompositorOGL::GetShaderConfigFor(GLenum aTarget, gfx::SurfaceFormat aFormat) const
{
ShaderConfigOGL config;
config.SetTextureTarget(aTarget);
config.SetRBSwap(aFormat == gfx::FORMAT_B8G8R8A8 ||
aFormat == gfx::FORMAT_B8G8R8X8);
config.SetNoAlpha(aFormat == gfx::FORMAT_B8G8R8X8 ||
aFormat == gfx::FORMAT_R8G8B8X8 ||
aFormat == gfx::FORMAT_R5G6B5);
return config;
}
ShaderProgramOGL*
CompositorOGL::GetShaderProgramFor(const ShaderConfigOGL &aConfig)
{
std::map<ShaderConfigOGL, ShaderProgramOGL *>::iterator iter = mPrograms.find(aConfig);
if (iter != mPrograms.end())
return iter->second;
ProgramProfileOGL profile(sUnifiedLayerVS, sUnifiedLayerFS);
typedef ProgramProfileOGL::Argument Argument;
profile.mUniforms.AppendElement(Argument("uLayerTransform"));
profile.mUniforms.AppendElement(Argument("uLayerQuadTransform"));
profile.mUniforms.AppendElement(Argument("uMatrixProj"));
profile.mUniforms.AppendElement(Argument("uRenderTargetOffset"));
profile.mAttributes.AppendElement(Argument("aVertexCoord"));
if (aConfig.mFeatures & ENABLE_RENDER_COLOR) {
profile.mDefines.AppendElement("#define ENABLE_RENDER_COLOR");
profile.mUniforms.AppendElement(Argument("uRenderColor"));
} else {
profile.mUniforms.AppendElement(Argument("uTextureTransform"));
profile.mAttributes.AppendElement(Argument("aTexCoord"));
if (aConfig.mFeatures & ENABLE_OPACITY) {
profile.mDefines.AppendElement("#define ENABLE_OPACITY");
profile.mUniforms.AppendElement(Argument("uLayerOpacity"));
}
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
profile.mDefines.AppendElement("#define ENABLE_TEXTURE_YCBCR");
profile.mUniforms.AppendElement(Argument("uYTexture"));
profile.mUniforms.AppendElement(Argument("uCbTexture"));
profile.mUniforms.AppendElement(Argument("uCrTexture"));
profile.mTextureCount = 3;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
profile.mDefines.AppendElement("#define ENABLE_TEXTURE_COMPONENT_ALPHA");
profile.mUniforms.AppendElement(Argument("uBlackTexture"));
profile.mUniforms.AppendElement(Argument("uWhiteTexture"));
profile.mUniforms.AppendElement(Argument("uTexturePass2"));
profile.mTextureCount = 2;
} else {
profile.mUniforms.AppendElement(Argument("uTexture"));
profile.mTextureCount = 1;
}
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
profile.mDefines.AppendElement("#define ENABLE_TEXTURE_RECT");
}
if (aConfig.mFeatures & ENABLE_TEXTURE_EXTERNAL) {
profile.mDefines.AppendElement("#define ENABLE_TEXTURE_EXTERNAL");
}
if (aConfig.mFeatures & ENABLE_TEXTURE_NO_ALPHA) {
profile.mDefines.AppendElement("#define ENABLE_TEXTURE_NO_ALPHA");
}
if (aConfig.mFeatures & ENABLE_TEXTURE_RB_SWAP) {
profile.mDefines.AppendElement("#define ENABLE_TEXTURE_RB_SWAP");
}
if (aConfig.mFeatures & ENABLE_BLUR) {
profile.mDefines.AppendElement("#define ENABLE_BLUR");
}
if (aConfig.mFeatures & ENABLE_COLOR_MATRIX) {
profile.mDefines.AppendElement("#define ENABLE_COLOR_MATRIX");
}
}
ShaderProgramOGL *shader = new ShaderProgramOGL(gl(), profile);
if (!shader->Initialize()) {
delete shader;
return nullptr;
}
mPrograms[aConfig] = shader;
return shader;
}
struct MOZ_STACK_CLASS AutoBindTexture
@ -1191,37 +1033,38 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
mPixelsFilled += aRect.width * aRect.height;
// Determine the color if this is a color shader and fold the opacity into
// the color since color shaders don't have an opacity uniform.
Color color;
if (aEffectChain.mPrimaryEffect->mType == EFFECT_SOLID_COLOR) {
EffectSolidColor* effectSolidColor =
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
color = effectSolidColor->mColor;
ShaderProgramType programType = GetProgramTypeForEffect(aEffectChain.mPrimaryEffect);
ShaderProgramOGL *program = GetProgram(programType, maskType);
program->Activate();
if (programType == RGBARectLayerProgramType ||
programType == RGBXRectLayerProgramType) {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
program->SetTexCoordMultiplier(source->GetSize().width, source->GetSize().height);
}
program->SetLayerQuadRect(aRect);
program->SetLayerTransform(aTransform);
program->SetRenderOffset(aOffset.x, aOffset.y);
if (aOpacity != 1.f) {
switch (aEffectChain.mPrimaryEffect->mType) {
case EFFECT_SOLID_COLOR: {
EffectSolidColor* effectSolidColor =
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
Color color = effectSolidColor->mColor;
/* Multiply color by the layer opacity, as the shader
* ignores layer opacity and expects a final color to
* write to the color buffer. This saves a needless
* multiply in the fragment shader.
*/
Float opacity = aOpacity * color.a;
color.r *= opacity;
color.g *= opacity;
color.b *= opacity;
color.a = opacity;
aOpacity = 1.f;
}
}
ShaderConfigOGL config = GetShaderConfigFor(aEffectChain.mPrimaryEffect, maskType);
config.SetOpacity(aOpacity != 1.f);
ShaderProgramOGL *program = GetShaderProgramFor(config);
program->Activate();
program->SetProjectionMatrix(mProjMatrix);
program->SetLayerQuadRect(aRect);
program->SetLayerTransform(aTransform);
program->SetRenderOffset(aOffset.x, aOffset.y);
if (aOpacity != 1.f)
program->SetLayerOpacity(aOpacity);
switch (aEffectChain.mPrimaryEffect->mType) {
case EFFECT_SOLID_COLOR: {
program->SetRenderColor(color);
AutoBindTexture bindMask;
@ -1235,9 +1078,13 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
}
break;
case EFFECT_RGB: {
case EFFECT_BGRA:
case EFFECT_BGRX:
case EFFECT_RGBA:
case EFFECT_RGBX: {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
Rect textureCoords;
TextureSource *source = texturedEffect->mTexture;
if (!texturedEffect->mPremultiplied) {
@ -1246,12 +1093,14 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
}
AutoBindTexture bindSource(source->AsSourceOGL(), LOCAL_GL_TEXTURE0);
program->SetTextureTransform(source->AsSourceOGL()->GetTextureTransform());
mGLContext->ApplyFilterToBoundTexture(source->AsSourceOGL()->GetTextureTarget(),
ThebesFilter(texturedEffect->mFilter));
program->SetTextureTransform(source->AsSourceOGL()->GetEffectiveTextureTransform());
program->SetTextureUnit(0);
program->SetLayerOpacity(aOpacity);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
@ -1293,6 +1142,7 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
mGLContext->ApplyFilterToBoundTexture(filter);
program->SetYCbCrTextureUnits(Y, Cb, Cr);
program->SetLayerOpacity(aOpacity);
program->SetTextureTransform(gfx3DMatrix());
AutoBindTexture bindMask;
@ -1310,12 +1160,14 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
RefPtr<CompositingRenderTargetOGL> surface
= static_cast<CompositingRenderTargetOGL*>(effectRenderTarget->mRenderTarget.get());
ShaderProgramOGL *program = GetProgram(GetFBOLayerProgramType(), maskType);
surface->BindTexture(LOCAL_GL_TEXTURE0, mFBOTextureTarget);
program->SetTextureTransform((mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB)
? gfx3DMatrix::ScalingMatrix(aRect.width, aRect.height, 1.0f)
: gfx3DMatrix());
program->Activate();
program->SetTextureUnit(0);
program->SetLayerOpacity(aOpacity);
program->SetTextureTransform(gfx3DMatrix());
AutoBindTexture bindMask;
if (maskType != MaskNone) {
@ -1324,6 +1176,11 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
program->SetMaskLayerTransform(maskQuadTransform);
}
if (program->GetTexCoordMultiplierUniformLocation() != -1) {
// 2DRect case, get the multiplier right for a sampler2DRect
program->SetTexCoordMultiplier(aRect.width, aRect.height);
}
// Drawing is always flipped, but when copying between surfaces we want to avoid
// this. Pass true for the flip parameter to introduce a second flip
// that cancels the other one out.
@ -1343,34 +1200,47 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
return;
}
AutoBindTexture bindSourceOnBlack(sourceOnBlack, LOCAL_GL_TEXTURE0);
AutoBindTexture bindSourceOnWhite(sourceOnWhite, LOCAL_GL_TEXTURE1);
for (int32_t pass = 1; pass <=2; ++pass) {
ShaderProgramOGL* program;
if (pass == 1) {
ShaderProgramType type = gl()->GetPreferredARGB32Format() == LOCAL_GL_BGRA ?
ComponentAlphaPass1RGBProgramType :
ComponentAlphaPass1ProgramType;
program = GetProgram(type, maskType);
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
LOCAL_GL_ONE, LOCAL_GL_ONE);
} else {
ShaderProgramType type = gl()->GetPreferredARGB32Format() == LOCAL_GL_BGRA ?
ComponentAlphaPass2RGBProgramType :
ComponentAlphaPass2ProgramType;
program = GetProgram(type, maskType);
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
LOCAL_GL_ONE, LOCAL_GL_ONE);
}
program->SetBlackTextureUnit(0);
program->SetWhiteTextureUnit(1);
program->SetTextureTransform(gfx3DMatrix());
AutoBindTexture bindSourceOnBlack(sourceOnBlack, LOCAL_GL_TEXTURE0);
AutoBindTexture bindSourceOnWhite(sourceOnWhite, LOCAL_GL_TEXTURE1);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE2);
program->SetMaskTextureUnit(2);
program->SetMaskLayerTransform(maskQuadTransform);
program->Activate();
program->SetBlackTextureUnit(0);
program->SetWhiteTextureUnit(1);
program->SetLayerOpacity(aOpacity);
program->SetLayerTransform(aTransform);
program->SetTextureTransform(gfx3DMatrix());
program->SetRenderOffset(aOffset.x, aOffset.y);
program->SetLayerQuadRect(aRect);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE2);
program->SetMaskTextureUnit(2);
program->SetMaskLayerTransform(maskQuadTransform);
}
BindAndDrawQuadWithTextureRect(program, effectComponentAlpha->mTextureCoords, effectComponentAlpha->mOnBlack);
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
LOCAL_GL_ONE, LOCAL_GL_ONE);
}
// Pass 1.
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
LOCAL_GL_ONE, LOCAL_GL_ONE);
program->SetTexturePass2(false);
BindAndDrawQuadWithTextureRect(program, effectComponentAlpha->mTextureCoords, effectComponentAlpha->mOnBlack);
// Pass 2.
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
LOCAL_GL_ONE, LOCAL_GL_ONE);
program->SetTexturePass2(true);
BindAndDrawQuadWithTextureRect(program, effectComponentAlpha->mTextureCoords, effectComponentAlpha->mOnBlack);
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
LOCAL_GL_ONE, LOCAL_GL_ONE);
}
break;
default:
@ -1426,7 +1296,13 @@ CompositorOGL::EndFrame()
}
if (mFPS) {
DrawFPS();
float fillRatio = 0;
if (mPixelsFilled > 0 && mPixelsPerFrame > 0) {
fillRatio = 100.0f * float(mPixelsFilled) / float(mPixelsPerFrame);
if (fillRatio > 999.0f)
fillRatio = 999.0f;
}
mFPS->DrawFPS(TimeStamp::Now(), unsigned(fillRatio), mGLContext, GetProgram(RGBXLayerProgramType));
}
mGLContext->SwapBuffers();

View File

@ -31,7 +31,6 @@
#include "nsXULAppAPI.h" // for XRE_GetProcessType
#include "nscore.h" // for NS_IMETHOD
#include "VBOArena.h" // for gl::VBOArena
#include <map>
class gfx3DMatrix;
class nsIWidget;
@ -55,45 +54,13 @@ struct Effect;
struct EffectChain;
struct FPSState;
class ShaderConfigOGL
{
public:
ShaderConfigOGL() :
mFeatures(0) {}
void SetRenderColor(bool aEnabled);
void SetTextureTarget(GLenum aTarget);
void SetRBSwap(bool aEnabled);
void SetNoAlpha(bool aEnabled);
void SetOpacity(bool aEnabled);
void SetYCbCr(bool aEnabled);
void SetComponentAlpha(bool aEnabled);
void SetColorMatrix(bool aEnabled);
void SetBlur(bool aEnabled);
void SetMask(bool aEnabled);
bool operator< (const ShaderConfigOGL& other) const {
return mFeatures < other.mFeatures;
}
public:
void SetFeature(int aBitmask, bool aState) {
if (aState)
mFeatures |= aBitmask;
else
mFeatures &= (~aBitmask);
}
int mFeatures;
};
class CompositorOGL : public Compositor
{
typedef mozilla::gl::GLContext GLContext;
typedef ShaderProgramType ProgramType;
friend class GLManagerCompositor;
std::map<ShaderConfigOGL, ShaderProgramOGL*> mPrograms;
public:
CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth = -1, int aSurfaceHeight = -1,
bool aUseExternalSurfaceSize = false);
@ -183,6 +150,10 @@ public:
}
GLContext* gl() const { return mGLContext; }
ShaderProgramType GetFBOLayerProgramType() const {
return mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB ?
RGBARectLayerProgramType : RGBALayerProgramType;
}
gfx::SurfaceFormat GetFBOFormat() const {
return gfx::FORMAT_R8G8B8A8;
}
@ -197,10 +168,6 @@ public:
* (see https://wiki.mozilla.org/Platform/GFX/Gralloc)
*/
GLuint GetTemporaryTexture(GLenum aUnit);
const gfx3DMatrix& GetProjMatrix() const {
return mProjMatrix;
}
private:
/**
* Context target, nullptr when drawing directly to our swap chain.
@ -211,7 +178,6 @@ private:
nsIWidget *mWidget;
nsIntSize mWidgetSize;
nsRefPtr<GLContext> mGLContext;
gfx3DMatrix mProjMatrix;
/** The size of the surface we are rendering to */
nsIntSize mSurfaceSize;
@ -226,6 +192,19 @@ private:
already_AddRefed<mozilla::gl::GLContext> CreateContext();
/** Shader Programs */
struct ShaderProgramVariations {
nsAutoTArray<nsAutoPtr<ShaderProgramOGL>, NumMaskTypes> mVariations;
ShaderProgramVariations() {
MOZ_COUNT_CTOR(ShaderProgramVariations);
mVariations.SetLength(NumMaskTypes);
}
~ShaderProgramVariations() {
MOZ_COUNT_DTOR(ShaderProgramVariations);
}
};
nsTArray<ShaderProgramVariations> mPrograms;
/** Texture target to use for FBOs */
GLenum mFBOTextureTarget;
@ -269,9 +248,24 @@ private:
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
ShaderProgramType GetProgramTypeForEffect(Effect* aEffect) const;
ShaderConfigOGL GetShaderConfigFor(GLenum aTarget, gfx::SurfaceFormat aFormat) const;
ShaderConfigOGL GetShaderConfigFor(Effect *aEffect, MaskType aMask = MaskNone) const;
ShaderProgramOGL* GetShaderProgramFor(const ShaderConfigOGL &aConfig);
/**
* Updates all layer programs with a new projection matrix.
*/
void SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix);
/**
* Helper method for Initialize, creates all valid variations of a program
* and adds them to mPrograms
*/
void AddPrograms(ShaderProgramType aType);
ShaderProgramOGL* GetProgram(ShaderProgramType aType,
MaskType aMask = MaskNone) {
MOZ_ASSERT(ProgramProfileOGL::ProgramExists(aType, aMask),
"Invalid program type.");
return mPrograms[aType].mVariations[aMask];
}
/**
* Create a FBO backed by a texture.
@ -313,8 +307,6 @@ private:
* Records the passed frame timestamp and returns the current estimated FPS.
*/
double AddFrameAndGetFps(const TimeStamp& timestamp);
void DrawFPS();
GLuint mFPSTexture;
bool mDestroyed;

View File

@ -216,7 +216,6 @@ ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer,
mOGLManager->GetFBOLayerProgram(maskType);
rgb->Activate();
rgb->SetProjectionMatrix(mOGLManager->mProjMatrix);
rgb->SetLayerQuadRect(visibleRect);
rgb->SetLayerTransform(transform);
rgb->SetTextureTransform(gfx3DMatrix());
@ -225,7 +224,8 @@ ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer,
rgb->SetTextureUnit(0);
rgb->LoadMask(GetMaskLayer());
if (rgb->HasTexCoordMultiplier()) {
if (rgb->GetTexCoordMultiplierUniformLocation() != -1) {
// 2DRect case, get the multiplier right for a sampler2DRect
rgb->SetTexCoordMultiplier(visibleRect.width, visibleRect.height);
}

View File

@ -68,10 +68,14 @@ private:
};
struct FPSState {
GLuint mTexture;
FPSCounter mCompositionFps;
FPSCounter mTransactionFps;
gl::VBOArena mVBOs;
FPSState() { }
FPSState() : mTexture(0) { }
void DrawFPS(TimeStamp, unsigned, gl::GLContext*, ShaderProgramOGL*);
void NotifyShadowTreeTransaction() {
mTransactionFps.AddFrame(TimeStamp::Now());

View File

@ -23,35 +23,6 @@ using namespace mozilla::gl;
namespace mozilla {
namespace layers {
inline ShaderProgramType
GetProgramTypeForSurfaceFormat(GLenum aTarget, gfx::SurfaceFormat aFormat)
{
if (aTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB) {
switch (aFormat) {
case gfx::FORMAT_R8G8B8X8:
case gfx::FORMAT_R5G6B5:
return RGBXRectLayerProgramType;
case gfx::FORMAT_R8G8B8A8:
return RGBARectLayerProgramType;
default:
MOZ_CRASH("unhandled program type");
}
}
switch (aFormat) {
case gfx::FORMAT_B8G8R8A8:
return BGRALayerProgramType;
case gfx::FORMAT_B8G8R8X8:
return BGRXLayerProgramType;
case gfx::FORMAT_R8G8B8X8:
case gfx::FORMAT_R5G6B5:
return RGBXLayerProgramType;
case gfx::FORMAT_R8G8B8A8:
return RGBALayerProgramType;
default:
MOZ_CRASH("unhandled program type");
}
}
class GLManagerLayerManager : public GLManager
{
public:
@ -64,14 +35,9 @@ public:
return mImpl->gl();
}
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) MOZ_OVERRIDE
{
return mImpl->GetProgram(GetProgramTypeForSurfaceFormat(aTarget, aFormat));
}
virtual gfx3DMatrix& GetProjMatrix() const MOZ_OVERRIDE
{
return mImpl->mProjMatrix;
return mImpl->GetProgram(aType);
}
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE
@ -95,15 +61,9 @@ public:
return mImpl->gl();
}
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) MOZ_OVERRIDE
{
ShaderConfigOGL config = mImpl->GetShaderConfigFor(aTarget, aFormat);
return mImpl->GetShaderProgramFor(config);
}
virtual const gfx3DMatrix& GetProjMatrix() const MOZ_OVERRIDE
{
return mImpl->GetProjMatrix();
return mImpl->GetProgram(aType);
}
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE

View File

@ -31,9 +31,12 @@ public:
virtual ~GLManager() {}
virtual gl::GLContext* gl() const = 0;
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) = 0;
virtual const gfx3DMatrix& GetProjMatrix() const = 0;
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) = 0;
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) = 0;
ShaderProgramOGL* GetProgram(gfx::SurfaceFormat aFormat) {
return GetProgram(ShaderProgramFromSurfaceFormat(aFormat));
}
};
}

View File

@ -261,7 +261,6 @@ ImageLayerOGL::RenderLayer(int,
GetMaskLayer());
program->Activate();
program->SetProjectionMatrix(mOGLManager->mProjMatrix);
program->SetLayerQuadRect(nsIntRect(0, 0,
yuvImage->GetSize().width,
yuvImage->GetSize().height));
@ -321,7 +320,6 @@ ImageLayerOGL::RenderLayer(int,
gl()->ApplyFilterToBoundTexture(mFilter);
program->Activate();
program->SetProjectionMatrix(mOGLManager->mProjMatrix);
program->SetLayerQuadRect(nsIntRect(0, 0,
cairoImage->GetSize().width,
cairoImage->GetSize().height));
@ -349,7 +347,6 @@ ImageLayerOGL::RenderLayer(int,
ShaderProgramOGL* program = mOGLManager->GetProgram(programType, GetMaskLayer());
program->Activate();
program->SetProjectionMatrix(mOGLManager->mProjMatrix);
if (programType == RGBARectLayerProgramType) {
// 2DRect case, get the multiplier right for a sampler2DRect
program->SetTexCoordMultiplier(data->mSize.width, data->mSize.height);

View File

@ -896,9 +896,7 @@ LayerManagerOGL::Render()
}
if (mFPS) {
// Disabled due to a refactoring in CompositorOGL.cpp. This file is about to be
// deleted anyway.
// mFPS->DrawFPS(TimeStamp::Now(), 0, mGLContext, GetProgram(Copy2DProgramType));
mFPS->DrawFPS(TimeStamp::Now(), 0, mGLContext, GetProgram(Copy2DProgramType));
}
if (mGLContext->IsDoubleBuffered()) {
@ -921,10 +919,9 @@ LayerManagerOGL::Render()
mGLContext->fBindTexture(mFBOTextureTarget, mBackBufferTexture);
copyprog->Activate();
copyprog->SetProjectionMatrix(mProjMatrix);
copyprog->SetTextureUnit(0);
if (copyprog->HasTexCoordMultiplier()) {
if (copyprog->GetTexCoordMultiplierUniformLocation() != -1) {
copyprog->SetTexCoordMultiplier(width, height);
}
@ -1057,7 +1054,7 @@ LayerManagerOGL::SetupPipeline(int aWidth, int aHeight, WorldTransforPolicy aTra
gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
matrix3d._33 = 0.0f;
mProjMatrix = matrix3d;
SetLayerProgramProjectionMatrix(matrix3d);
}
void
@ -1161,6 +1158,18 @@ LayerManagerOGL::CopyToTarget(gfxContext *aTarget)
aTarget->Paint();
}
void
LayerManagerOGL::SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix)
{
for (unsigned int i = 0; i < mPrograms.Length(); ++i) {
for (uint32_t mask = MaskNone; mask < NumMaskTypes; ++mask) {
if (mPrograms[i].mVariations[mask]) {
mPrograms[i].mVariations[mask]->CheckAndSetProjectionMatrix(aMatrix);
}
}
}
}
static GLenum
GetFrameBufferInternalFormat(GLContext* gl,
GLuint aCurrentFrameBuffer,

View File

@ -334,8 +334,6 @@ public:
*/
float ComputeRenderIntegrity();
gfx3DMatrix mProjMatrix;
private:
/** Widget associated with this layer manager */
nsIWidget *mWidget;
@ -413,6 +411,11 @@ private:
*/
void CopyToTarget(gfxContext *aTarget);
/**
* Updates all layer programs with a new projection matrix.
*/
void SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix);
/**
* Helper method for Initialize, creates all valid variations of a program
* and adds them to mPrograms

View File

@ -4,7 +4,6 @@
#include "LayerManagerOGLProgram.h"
#include <stdint.h> // for uint32_t
#include <sstream> // for ostringstream
#include "gfxMatrix.h" // for gfxMatrix
#include "gfxPoint.h" // for gfxIntSize, gfxPoint, etc
#include "gfxRect.h" // for gfxRect
@ -23,8 +22,6 @@ struct gfxRGBA;
namespace mozilla {
namespace layers {
using namespace std;
typedef ProgramProfileOGL::Argument Argument;
// helper methods for GetProfileFor
@ -34,6 +31,7 @@ AddCommonArgs(ProgramProfileOGL& aProfile)
aProfile.mUniforms.AppendElement(Argument("uLayerTransform"));
aProfile.mUniforms.AppendElement(Argument("uLayerQuadTransform"));
aProfile.mUniforms.AppendElement(Argument("uMatrixProj"));
aProfile.mHasMatrixProj = true;
aProfile.mUniforms.AppendElement(Argument("uRenderTargetOffset"));
aProfile.mAttributes.AppendElement(Argument("aVertexCoord"));
}
@ -46,12 +44,6 @@ AddCommonTextureArgs(ProgramProfileOGL& aProfile)
aProfile.mAttributes.AppendElement(Argument("aTexCoord"));
}
void
AddConfig(ProgramProfileOGL& aProfile, const char *aConfig)
{
aProfile.mDefines.AppendElement(aConfig);
}
/* static */ ProgramProfileOGL
ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
MaskType aMask)
@ -60,21 +52,6 @@ ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
ProgramProfileOGL result;
switch (aType) {
case YCbCrLayerProgramType:
result.mVertexShaderString = sUnifiedLayerVS;
result.mFragmentShaderString = sUnifiedLayerFS;
AddCommonArgs(result);
AddConfig(result, "#define ENABLE_TEXTURE_YCBCR");
if (aMask != MaskNone)
AddConfig(result, "#define ENABLE_MASK");
result.mUniforms.AppendElement(Argument("uLayerOpacity"));
result.mUniforms.AppendElement(Argument("uYTexture"));
result.mUniforms.AppendElement(Argument("uCbTexture"));
result.mUniforms.AppendElement(Argument("uCrTexture"));
result.mUniforms.AppendElement(Argument("uTextureTransform"));
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 3;
break;
case RGBALayerProgramType:
if (aMask == Mask3d) {
result.mVertexShaderString = sLayerMask3DVS;
@ -139,7 +116,6 @@ ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
}
AddCommonArgs(result);
AddCommonTextureArgs(result);
result.mUniforms.AppendElement(Argument("uTexCoordMultiplier"));
result.mTextureCount = 1;
break;
case RGBXRectLayerProgramType:
@ -155,7 +131,6 @@ ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
}
AddCommonArgs(result);
AddCommonTextureArgs(result);
result.mUniforms.AppendElement(Argument("uTexCoordMultiplier"));
result.mTextureCount = 1;
break;
case BGRARectLayerProgramType:
@ -164,7 +139,6 @@ ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
result.mFragmentShaderString = sBGRARectTextureLayerFS;
AddCommonArgs(result);
AddCommonTextureArgs(result);
result.mUniforms.AppendElement(Argument("uTexCoordMultiplier"));
result.mTextureCount = 1;
break;
case RGBAExternalLayerProgramType:
@ -193,6 +167,23 @@ ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
AddCommonArgs(result);
result.mUniforms.AppendElement(Argument("uRenderColor"));
break;
case YCbCrLayerProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
result.mFragmentShaderString = sYCbCrTextureLayerMaskFS;
} else {
result.mVertexShaderString = sLayerVS;
result.mFragmentShaderString = sYCbCrTextureLayerFS;
}
AddCommonArgs(result);
result.mUniforms.AppendElement(Argument("uLayerOpacity"));
result.mUniforms.AppendElement(Argument("uYTexture"));
result.mUniforms.AppendElement(Argument("uCbTexture"));
result.mUniforms.AppendElement(Argument("uCrTexture"));
result.mUniforms.AppendElement(Argument("uTextureTransform"));
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 3;
break;
case ComponentAlphaPass1ProgramType:
if (aMask == Mask2d) {
result.mVertexShaderString = sLayerMaskVS;
@ -273,7 +264,6 @@ ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
result.mFragmentShaderString = sCopy2DRectFS;
result.mUniforms.AppendElement(Argument("uTexture"));
result.mUniforms.AppendElement(Argument("uTextureTransform"));
result.mUniforms.AppendElement(Argument("uTexCoordMultiplier"));
result.mAttributes.AppendElement(Argument("aVertexCoord"));
result.mAttributes.AppendElement(Argument("aTexCoord"));
result.mTextureCount = 1;
@ -295,7 +285,8 @@ const char* const ShaderProgramOGL::VertexCoordAttrib = "aVertexCoord";
const char* const ShaderProgramOGL::TexCoordAttrib = "aTexCoord";
ShaderProgramOGL::ShaderProgramOGL(GLContext* aGL, const ProgramProfileOGL& aProfile)
: mGL(aGL)
: mIsProjectionMatrixStale(false)
, mGL(aGL)
, mProgram(0)
, mProfile(aProfile)
, mProgramState(STATE_NEW)
@ -320,15 +311,8 @@ ShaderProgramOGL::Initialize()
{
NS_ASSERTION(mProgramState == STATE_NEW, "Shader program has already been initialised");
ostringstream vs, fs;
for (uint32_t i = 0; i < mProfile.mDefines.Length(); ++i) {
vs << mProfile.mDefines[i] << endl;
fs << mProfile.mDefines[i] << endl;
}
vs << mProfile.mVertexShaderString << endl;
fs << mProfile.mFragmentShaderString << endl;
if (!CreateProgram(vs.str().c_str(), fs.str().c_str())) {
if (!CreateProgram(mProfile.mVertexShaderString,
mProfile.mFragmentShaderString)) {
mProgramState = STATE_ERROR;
return false;
}
@ -347,6 +331,10 @@ ShaderProgramOGL::Initialize()
NS_ASSERTION(mProfile.mAttributes[i].mLocation >= 0, "Bad attribute location.");
}
// this is a one-off that's present in the 2DRect versions of some shaders.
mTexCoordMultiplierUniformLocation =
mGL->fGetUniformLocation(mProgram, "uTexCoordMultiplier");
return true;
}
@ -499,6 +487,10 @@ ShaderProgramOGL::Activate()
#if CHECK_CURRENT_PROGRAM
mGL->SetUserData(&sCurrentProgramKey, this);
#endif
// check and set the projection matrix
if (mIsProjectionMatrixStale) {
SetProjectionMatrix(mProjectionMatrix);
}
}

View File

@ -31,8 +31,6 @@ namespace layers {
class Layer;
enum ShaderProgramType {
ColorLayerProgramType,
YCbCrLayerProgramType,
RGBALayerProgramType,
BGRALayerProgramType,
RGBXLayerProgramType,
@ -41,6 +39,8 @@ enum ShaderProgramType {
RGBXRectLayerProgramType,
BGRARectLayerProgramType,
RGBAExternalLayerProgramType,
ColorLayerProgramType,
YCbCrLayerProgramType,
ComponentAlphaPass1ProgramType,
ComponentAlphaPass1RGBProgramType,
ComponentAlphaPass2ProgramType,
@ -186,12 +186,12 @@ struct ProgramProfileOGL
nsTArray<Argument> mUniforms;
nsTArray<Argument> mAttributes;
nsTArray<const char *> mDefines;
uint32_t mTextureCount;
ProgramProfileOGL(const char *aVS = nullptr, const char *aFS = nullptr) :
mVertexShaderString(aVS), mFragmentShaderString(aFS), mTextureCount(0)
{}
bool mHasMatrixProj;
private:
ProgramProfileOGL() :
mTextureCount(0),
mHasMatrixProj(false) {}
};
@ -243,6 +243,10 @@ public:
return mProfile.LookupAttributeLocation(aName);
}
GLint GetTexCoordMultiplierUniformLocation() {
return mTexCoordMultiplierUniformLocation;
}
/**
* aLayer is the mask layer to use for rendering, or null, if there is no
* mask layer.
@ -292,8 +296,18 @@ public:
SetMatrixUniform(mProfile.LookupUniformLocation("uLayerQuadTransform"), m);
}
// activates this program and sets its projection matrix, if the program uses one
void CheckAndSetProjectionMatrix(const gfx3DMatrix& aMatrix)
{
if (mProfile.mHasMatrixProj) {
mIsProjectionMatrixStale = true;
mProjectionMatrix = aMatrix;
}
}
void SetProjectionMatrix(const gfx3DMatrix& aMatrix) {
SetMatrixUniform(mProfile.LookupUniformLocation("uMatrixProj"), aMatrix);
mIsProjectionMatrixStale = false;
}
// sets this program's texture transform, if it uses one
@ -360,20 +374,9 @@ public:
SetUniform(mProfile.LookupUniformLocation("uRenderColor"), aColor);
}
bool HasTexCoordMultiplier() {
return mProfile.LookupUniformLocation("uTexCoordMultiplier") != -1;
}
void SetTexCoordMultiplier(float aWidth, float aHeight) {
float f[] = {aWidth, aHeight};
SetUniform(mProfile.LookupUniformLocation("uTexCoordMultiplier"), 2, f);
}
// Set whether we want the component alpha shader to return the color
// vector (pass 1, false) or the alpha vector (pass 2, true). With support
// for multiple render targets we wouldn't need two passes here.
void SetTexturePass2(bool aFlag) {
SetUniform(mProfile.LookupUniformLocation("uTexturePass2"), aFlag ? 1 : 0);
SetUniform(mTexCoordMultiplierUniformLocation, 2, f);
}
// the names of attributes
@ -381,6 +384,10 @@ public:
static const char* const TexCoordAttrib;
protected:
gfx3DMatrix mProjectionMatrix;
// true if the projection matrix needs setting
bool mIsProjectionMatrixStale;
RefPtr<GLContext> mGL;
// the OpenGL id of the program
GLuint mProgram;
@ -391,6 +398,7 @@ protected:
STATE_ERROR
} mProgramState;
GLint mTexCoordMultiplierUniformLocation;
#ifdef CHECK_CURRENT_PROGRAM
static int sCurrentProgramKey;
#endif

View File

@ -114,7 +114,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -141,7 +143,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -170,7 +174,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -196,7 +202,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -225,7 +233,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -256,7 +266,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -292,7 +304,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -331,7 +345,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -371,7 +387,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -407,7 +425,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -446,7 +466,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -486,7 +508,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -512,7 +536,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -539,7 +565,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -569,7 +597,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -599,7 +629,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -625,7 +657,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -654,7 +688,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -680,7 +716,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -709,7 +747,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -735,7 +775,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -754,109 +796,37 @@ gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * m
}\n\
";
static const char sUnifiedLayerVS[] = "/* sUnifiedLayerVS */\n\
/* Vertex Shader */\n\
uniform mat4 uMatrixProj;\n\
uniform mat4 uLayerQuadTransform;\n\
uniform mat4 uLayerTransform;\n\
uniform vec4 uRenderTargetOffset;\n\
attribute vec4 aVertexCoord;\n\
#ifndef ENABLE_RENDER_COLOR\n\
uniform mat4 uTextureTransform;\n\
attribute vec2 aTexCoord;\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
varying vec2 vTexCoord;\n\
#endif\n\
#endif\n\
#ifdef ENABLE_MASK\n\
uniform mat4 uMaskQuadTransform;\n\
varying vec3 vMaskCoord;\n\
#endif\n\
void main()\n\
{\n\
vec4 finalPosition = aVertexCoord;\n\
finalPosition = uLayerQuadTransform * finalPosition;\n\
finalPosition = uLayerTransform * finalPosition;\n\
finalPosition.xyz /= finalPosition.w;\n\
#ifdef ENABLE_MASK\n\
vMaskCoord.xy = (uMaskQuadTransform * vec4(finalPosition.xyz, 1.0)).xy;\n\
// correct for perspective correct interpolation, see comment in D3D10 shader\n\
vMaskCoord.z = 1.0;\n\
vMaskCoord *= finalPosition.w;\n\
#endif\n\
finalPosition = finalPosition - uRenderTargetOffset;\n\
finalPosition.xyz *= finalPosition.w;\n\
finalPosition = uMatrixProj * finalPosition;\n\
#ifndef ENABLE_RENDER_COLOR\n\
vTexCoord = (uTextureTransform * vec4(aTexCoord.x, aTexCoord.y, 0.0, 1.0)).xy;\n\
#endif\n\
gl_Position = finalPosition;\n\
}\n\
";
static const char sUnifiedLayerFS[] = "/* sUnifiedLayerFS */\n\
static const char sYCbCrTextureLayerFS[] = "/* sYCbCrTextureLayerFS */\n\
/* Fragment Shader */\n\
#ifdef GL_ES\n\
#ifdef MEDIUMP_SHADER\n\
precision mediump float;\n\
#else\n\
precision lowp float;\n\
#endif\n\
#ifdef ENABLE_RENDER_COLOR\n\
uniform vec4 uRenderColor;\n\
#else\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
varying vec2 vTexCoord;\n\
#endif\n\
#ifdef ENABLE_OPACITY\n\
uniform float uLayerOpacity;\n\
\n\
#ifdef GL_ES\n\
precision mediump float;\n\
#endif\n\
#endif\n\
#ifdef ENABLE_TEXTURE_RECT\n\
#extension GL_ARB_texture_rectangle : require\n\
#define sampler2D sampler2DRect\n\
#define texture2D texture2DRect\n\
#endif\n\
#ifdef ENABLE_TEXTURE_EXTERNAL\n\
#extension GL_OES_EGL_image_external : require\n\
#define sampler2D samplerExternalOES\n\
#endif\n\
#ifdef ENABLE_TEXTURE_YCBCR\n\
uniform sampler2D uYTexture;\n\
uniform sampler2D uCbTexture;\n\
uniform sampler2D uCrTexture;\n\
#else\n\
#ifdef ENABLE_TEXTURE_COMPONENT_ALPHA\n\
uniform sampler2D uBlackTexture;\n\
uniform sampler2D uWhiteTexture;\n\
uniform bool uTexturePass2;\n\
#else\n\
uniform sampler2D uTexture;\n\
#endif\n\
#endif\n\
#ifdef ENABLE_BLUR\n\
uniform bool uBlurAlpha;\n\
uniform vec2 uBlurRadius;\n\
uniform vec2 uBlurOffset;\n\
#define GAUSSIAN_KERNEL_HALF_WIDTH 11\n\
#define GAUSSIAN_KERNEL_STEP 0.2\n\
uniform float uBlurGaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];\n\
#endif\n\
#ifdef ENABLE_COLOR_MATRIX\n\
uniform mat4 uColorMatrix;\n\
uniform vec4 uColorMatrixVector;\n\
#endif\n\
#ifdef ENABLE_MASK\n\
varying vec3 vMaskCoord;\n\
uniform sampler2D uMaskTexture;\n\
#endif\n\
vec4 sample(vec2 coord)\n\
void main()\n\
{\n\
vec4 color;\n\
#ifdef ENABLE_TEXTURE_YCBCR\n\
float y = texture2D(uYTexture, coord).r;\n\
float cb = texture2D(uCbTexture, coord).r;\n\
float cr = texture2D(uCrTexture, coord).r;\n\
float y = texture2D(uYTexture, vTexCoord).r;\n\
float cb = texture2D(uCbTexture, vTexCoord).r;\n\
float cr = texture2D(uCrTexture, vTexCoord).r;\n\
y = (y - 0.0625) * 1.164;\n\
cb = cb - 0.5;\n\
cr = cr - 0.5;\n\
@ -864,74 +834,56 @@ color.r = y + cr * 1.596;\n\
color.g = y - 0.813 * cr - 0.391 * cb;\n\
color.b = y + cb * 2.018;\n\
color.a = 1.0;\n\
float mask = 1.0;\n\
\n\
gl_FragColor = color * uLayerOpacity * mask;\n\
}\n\
";
static const char sYCbCrTextureLayerMaskFS[] = "/* sYCbCrTextureLayerMaskFS */\n\
/* Fragment Shader */\n\
#ifdef GL_ES\n\
#ifdef MEDIUMP_SHADER\n\
precision mediump float;\n\
#else\n\
#ifdef ENABLE_TEXTURE_COMPONENT_ALPHA\n\
vec3 onBlack = texture2D(uBlackTexture, coord).rgb;\n\
vec3 onWhite = texture2D(uWhiteTexture, coord).rgb;\n\
vec4 alphas = (1.0 - onWhite + onBlack).rgbg;\n\
if (uTexturePass2)\n\
color = vec4(onBlack, alphas.a);\n\
else\n\
color = alphas;\n\
precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
color = texture2D(uTexture, coord);\n\
varying vec2 vTexCoord;\n\
#endif\n\
\n\
varying vec2 vMaskCoord;\n\
uniform sampler2D uMaskTexture;\n\
\n\
#ifdef GL_ES\n\
precision mediump float;\n\
#endif\n\
#ifdef ENABLE_TEXTURE_RB_SWAP\n\
color = color.bgra;\n\
#endif\n\
#ifdef ENABLE_TEXTURE_NO_ALPHA\n\
color = vec4(color.rgb, 1.0);\n\
#endif\n\
return color;\n\
}\n\
#ifdef ENABLE_BLUR\n\
vec4 sampleAtRadius(vec2 coord, float radius) {\n\
coord += uBlurOffset;\n\
coord += radius * uBlurRadius;\n\
if (coord.x < 0. || coord.y < 0. || coord.x > 1. || coord.y > 1.)\n\
return vec4(0, 0, 0, 0);\n\
return sample(coord);\n\
}\n\
vec4 blur(vec4 color, vec2 coord) {\n\
vec4 total = color * uBlurGaussianKernel[0];\n\
for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; ++i) {\n\
float r = float(i) * GAUSSIAN_KERNEL_STEP;\n\
float k = uBlurGaussianKernel[i];\n\
total += sampleAtRadius(coord, r) * k;\n\
total += sampleAtRadius(coord, -r) * k;\n\
}\n\
if (uBlurAlpha) {\n\
color *= total.a;\n\
} else {\n\
color = total;\n\
}\n\
return color;\n\
}\n\
#endif\n\
uniform sampler2D uYTexture;\n\
uniform sampler2D uCbTexture;\n\
uniform sampler2D uCrTexture;\n\
void main()\n\
{\n\
vec4 color;\n\
#ifdef ENABLE_RENDER_COLOR\n\
color = uRenderColor;\n\
#else\n\
color = sample(vTexCoord);\n\
#ifdef ENABLE_BLUR\n\
color = blur(color, vTexCoord);\n\
#endif\n\
#ifdef ENABLE_COLOR_MATRIX\n\
color = uColorMatrix * vec4(color.rgb / color.a, color.a) + uColorMatrixVector;\n\
color.rgb *= color.a;\n\
#endif\n\
#ifdef ENABLE_OPACITY\n\
color *= uLayerOpacity;\n\
#endif\n\
#endif\n\
#ifdef ENABLE_MASK\n\
vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;\n\
color *= texture2D(uMaskTexture, maskCoords).r;\n\
#endif\n\
gl_FragColor = color;\n\
float y = texture2D(uYTexture, vTexCoord).r;\n\
float cb = texture2D(uCbTexture, vTexCoord).r;\n\
float cr = texture2D(uCrTexture, vTexCoord).r;\n\
y = (y - 0.0625) * 1.164;\n\
cb = cb - 0.5;\n\
cr = cr - 0.5;\n\
color.r = y + cr * 1.596;\n\
color.g = y - 0.813 * cr - 0.391 * cb;\n\
color.b = y + cb * 2.018;\n\
color.a = 1.0;\n\
float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
\n\
gl_FragColor = color * uLayerOpacity * mask;\n\
}\n\
";
@ -945,7 +897,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -975,7 +929,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -1008,7 +964,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -1038,7 +996,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -1071,7 +1031,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -1101,7 +1063,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -1134,7 +1098,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\
@ -1164,7 +1130,9 @@ precision lowp float;\n\
#endif\n\
#endif\n\
\n\
#ifndef NO_LAYER_OPACITY\n\
uniform float uLayerOpacity;\n\
#endif\n\
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
varying mediump vec2 vTexCoord;\n\
#else\n\

View File

@ -149,7 +149,9 @@ precision lowp float;
@define LAYER_FRAGMENT<>
$FRAGMENT_SHADER_HEADER$
#ifndef NO_LAYER_OPACITY
uniform float uLayerOpacity;
#endif
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range
varying mediump vec2 vTexCoord;
@ -331,59 +333,7 @@ $FRAGMENT_CALC_MASK<mask>$
}
@end
@shader sUnifiedLayerVS
/* Vertex Shader */
uniform mat4 uMatrixProj;
uniform mat4 uLayerQuadTransform;
uniform mat4 uLayerTransform;
uniform vec4 uRenderTargetOffset;
attribute vec4 aVertexCoord;
#ifndef ENABLE_RENDER_COLOR
uniform mat4 uTextureTransform;
attribute vec2 aTexCoord;
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range
varying mediump vec2 vTexCoord;
#else
varying vec2 vTexCoord;
#endif
#endif
#ifdef ENABLE_MASK
uniform mat4 uMaskQuadTransform;
varying vec3 vMaskCoord;
#endif
void main()
{
vec4 finalPosition = aVertexCoord;
finalPosition = uLayerQuadTransform * finalPosition;
finalPosition = uLayerTransform * finalPosition;
finalPosition.xyz /= finalPosition.w;
#ifdef ENABLE_MASK
vMaskCoord.xy = (uMaskQuadTransform * vec4(finalPosition.xyz, 1.0)).xy;
// correct for perspective correct interpolation, see comment in D3D10 shader
vMaskCoord.z = 1.0;
vMaskCoord *= finalPosition.w;
#endif
finalPosition = finalPosition - uRenderTargetOffset;
finalPosition.xyz *= finalPosition.w;
finalPosition = uMatrixProj * finalPosition;
#ifndef ENABLE_RENDER_COLOR
vTexCoord = (uTextureTransform * vec4(aTexCoord.x, aTexCoord.y, 0.0, 1.0)).xy;
#endif
gl_Position = finalPosition;
}
@end
// Layer fragment shader
// Three textures, representing YCbCr planes of a video image.
//
// Some older versions of the Tegra 2 android driver have a bug
// where arithmetic ops on a texture read are just ignored. So,
@ -392,76 +342,22 @@ void main()
// rendering -- see bug 765150. Doing them separately like below
// makes it all OK. We don't know if this is special to constants,
// special to 0.5, special to addition/subtraction, etc.
@shader sUnifiedLayerFS
@shader sYCbCrTextureLayer<mask:,Mask>FS
$LAYER_FRAGMENT<mask>$
#ifdef GL_ES
precision lowp float;
precision mediump float;
#endif
#ifdef ENABLE_RENDER_COLOR
uniform vec4 uRenderColor;
#else
#ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range
varying mediump vec2 vTexCoord;
#else
varying vec2 vTexCoord;
#endif
#ifdef ENABLE_OPACITY
uniform float uLayerOpacity;
#endif
#endif
#ifdef ENABLE_TEXTURE_RECT
#extension GL_ARB_texture_rectangle : require
#define sampler2D sampler2DRect
#define texture2D texture2DRect
#endif
#ifdef ENABLE_TEXTURE_EXTERNAL
#extension GL_OES_EGL_image_external : require
#define sampler2D samplerExternalOES
#endif
#ifdef ENABLE_TEXTURE_YCBCR
uniform sampler2D uYTexture;
uniform sampler2D uCbTexture;
uniform sampler2D uCrTexture;
#else
#ifdef ENABLE_TEXTURE_COMPONENT_ALPHA
uniform sampler2D uBlackTexture;
uniform sampler2D uWhiteTexture;
uniform bool uTexturePass2;
#else
uniform sampler2D uTexture;
#endif
#endif
#ifdef ENABLE_BLUR
uniform bool uBlurAlpha;
uniform vec2 uBlurRadius;
uniform vec2 uBlurOffset;
#define GAUSSIAN_KERNEL_HALF_WIDTH 11
#define GAUSSIAN_KERNEL_STEP 0.2
uniform float uBlurGaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];
#endif
#ifdef ENABLE_COLOR_MATRIX
uniform mat4 uColorMatrix;
uniform vec4 uColorMatrixVector;
#endif
#ifdef ENABLE_MASK
varying vec3 vMaskCoord;
uniform sampler2D uMaskTexture;
#endif
vec4 sample(vec2 coord)
void main()
{
vec4 color;
#ifdef ENABLE_TEXTURE_YCBCR
float y = texture2D(uYTexture, coord).r;
float cb = texture2D(uCbTexture, coord).r;
float cr = texture2D(uCrTexture, coord).r;
float y = texture2D(uYTexture, vTexCoord).r;
float cb = texture2D(uCbTexture, vTexCoord).r;
float cr = texture2D(uCrTexture, vTexCoord).r;
y = (y - 0.0625) * 1.164;
cb = cb - 0.5;
@ -471,77 +367,8 @@ vec4 sample(vec2 coord)
color.g = y - 0.813 * cr - 0.391 * cb;
color.b = y + cb * 2.018;
color.a = 1.0;
#else
#ifdef ENABLE_TEXTURE_COMPONENT_ALPHA
vec3 onBlack = texture2D(uBlackTexture, coord).rgb;
vec3 onWhite = texture2D(uWhiteTexture, coord).rgb;
vec4 alphas = (1.0 - onWhite + onBlack).rgbg;
if (uTexturePass2)
color = vec4(onBlack, alphas.a);
else
color = alphas;
#else
color = texture2D(uTexture, coord);
#endif
#endif
#ifdef ENABLE_TEXTURE_RB_SWAP
color = color.bgra;
#endif
#ifdef ENABLE_TEXTURE_NO_ALPHA
color = vec4(color.rgb, 1.0);
#endif
return color;
}
#ifdef ENABLE_BLUR
vec4 sampleAtRadius(vec2 coord, float radius) {
coord += uBlurOffset;
coord += radius * uBlurRadius;
if (coord.x < 0. || coord.y < 0. || coord.x > 1. || coord.y > 1.)
return vec4(0, 0, 0, 0);
return sample(coord);
}
vec4 blur(vec4 color, vec2 coord) {
vec4 total = color * uBlurGaussianKernel[0];
for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; ++i) {
float r = float(i) * GAUSSIAN_KERNEL_STEP;
float k = uBlurGaussianKernel[i];
total += sampleAtRadius(coord, r) * k;
total += sampleAtRadius(coord, -r) * k;
}
if (uBlurAlpha) {
color *= total.a;
} else {
color = total;
}
return color;
}
#endif
void main()
{
vec4 color;
#ifdef ENABLE_RENDER_COLOR
color = uRenderColor;
#else
color = sample(vTexCoord);
#ifdef ENABLE_BLUR
color = blur(color, vTexCoord);
#endif
#ifdef ENABLE_COLOR_MATRIX
color = uColorMatrix * vec4(color.rgb / color.a, color.a) + uColorMatrixVector;
color.rgb *= color.a;
#endif
#ifdef ENABLE_OPACITY
color *= uLayerOpacity;
#endif
#endif
#ifdef ENABLE_MASK
vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;
color *= texture2D(uMaskTexture, maskCoords).r;
#endif
gl_FragColor = color;
$FRAGMENT_CALC_MASK<mask>$
gl_FragColor = color * uLayerOpacity * mask;
}
@end

View File

@ -97,6 +97,29 @@ protected:
* sequence as simple as possible.
*/
inline ShaderProgramType
GetProgramTypeForSurfaceFormat(gfx::SurfaceFormat aFormat)
{
switch (aFormat) {
case gfx::FORMAT_B8G8R8A8:
return BGRALayerProgramType;;
case gfx::FORMAT_B8G8R8X8:
return BGRXLayerProgramType;;
case gfx::FORMAT_R8G8B8X8:
return RGBXLayerProgramType;;
case gfx::FORMAT_R8G8B8A8:
return RGBALayerProgramType;;
default:
MOZ_CRASH("unhandled program type");
}
}
inline ShaderProgramType
GetProgramTypeForTexture(const DeprecatedTextureHost *aDeprecatedTextureHost)
{
return GetProgramTypeForSurfaceFormat(aDeprecatedTextureHost->GetFormat());
}
/**
* TextureSourceOGL provides the necessary API for CompositorOGL to composite
* a TextureSource.
@ -121,14 +144,6 @@ public:
virtual gfx3DMatrix GetTextureTransform() { return gfx3DMatrix(); }
virtual TextureImageDeprecatedTextureHostOGL* AsTextureImageDeprecatedTextureHost() { return nullptr; }
// Return the effective texture transform, compensating for the fact that
// IOSurface uses 0,0...w,h coordinate rather then 0,0..1,1.
const gfx3DMatrix GetEffectiveTextureTransform() {
if (GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB)
return GetTextureTransform() * gfx3DMatrix::ScalingMatrix(GetSize().width, GetSize().height, 1.0f);
return GetTextureTransform();
}
};
/**

View File

@ -197,7 +197,6 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
}
alphaProgram->Activate();
alphaProgram->SetProjectionMatrix(aManager->mProjMatrix);
alphaProgram->SetBlackTextureUnit(0);
alphaProgram->SetWhiteTextureUnit(1);
program = alphaProgram;
@ -209,7 +208,6 @@ ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
mLayer->GetMaskLayer());
basicProgram->Activate();
basicProgram->SetProjectionMatrix(aManager->mProjMatrix);
basicProgram->SetTextureUnit(0);
program = basicProgram;
}

View File

@ -338,16 +338,11 @@ public:
virtual ~GLPresenter();
virtual GLContext* gl() const MOZ_OVERRIDE { return mGLContext; }
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) MOZ_OVERRIDE
{
MOZ_ASSERT(aTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB);
MOZ_ASSERT(aFormat == gfx::FORMAT_R8G8B8A8);
MOZ_ASSERT(aType == RGBARectLayerProgramType, "unexpected program type");
return mRGBARectProgram;
}
virtual const gfx3DMatrix& GetProjMatrix() const MOZ_OVERRIDE
{
return mProjMatrix;
}
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE;
void BeginFrame(nsIntSize aRenderSize);
@ -362,7 +357,6 @@ public:
protected:
nsRefPtr<mozilla::gl::GLContext> mGLContext;
nsAutoPtr<mozilla::layers::ShaderProgramOGL> mRGBARectProgram;
gfx3DMatrix mProjMatrix;
GLuint mQuadVBO;
};
@ -2623,20 +2617,17 @@ RectTextureImage::Draw(GLManager* aManager,
const nsIntPoint& aLocation,
const gfx3DMatrix& aTransform)
{
ShaderProgramOGL* program = aManager->GetProgram(LOCAL_GL_TEXTURE_RECTANGLE_ARB,
gfx::FORMAT_R8G8B8A8);
ShaderProgramOGL* program = aManager->GetProgram(RGBARectLayerProgramType);
aManager->gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, mTexture);
program->Activate();
program->SetProjectionMatrix(aManager->GetProjMatrix());
program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0), mUsedSize));
program->SetLayerTransform(aTransform * gfx3DMatrix::Translation(aLocation.x, aLocation.y, 0));
program->SetTextureTransform(gfx3DMatrix::ScalingMatrix(mUsedSize.width, mUsedSize.height, 1.0f));
program->SetTextureTransform(gfx3DMatrix());
program->SetLayerOpacity(1.0);
program->SetRenderOffset(nsIntPoint(0, 0));
if (program->HasTexCoordMultiplier()) {
program->SetTexCoordMultiplier(1.0f, 1.0f);
}
program->SetTexCoordMultiplier(mUsedSize.width, mUsedSize.height);
program->SetTextureUnit(0);
aManager->BindAndDrawQuad(program);
@ -2678,7 +2669,7 @@ GLPresenter::~GLPresenter()
}
void
GLPresenter::BindAndDrawQuad(ShaderProgramOGL *aProgram)
GLPresenter::BindAndDrawQuad(ShaderProgramOGL* aProgram)
{
mGLContext->MakeCurrent();
@ -2716,7 +2707,7 @@ GLPresenter::BeginFrame(nsIntSize aRenderSize)
gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
matrix3d._33 = 0.0f;
mProjMatrix = matrix3d;
mRGBARectProgram->CheckAndSetProjectionMatrix(matrix3d);
// Default blend function implements "OVER"
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,