Bug 1223736 - Part 3: Remove the distinction between 2d and 3d masks since it only adds complexity. r=Bas

This commit is contained in:
Matt Woodrow 2016-03-22 09:10:37 +13:00
Родитель 1f94409ed4
Коммит b95fd6e721
23 изменённых файлов: 3619 добавлений и 5415 удалений

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

@ -230,8 +230,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(OpenMode)
// We rely on the items in this enum being sequential
enum class MaskType : uint8_t {
MaskNone = 0, // no mask layer
Mask2d, // mask layer for layers with 2D transforms
Mask3d, // mask layer for layers with 3D transforms
Mask, // mask layer
NumMaskTypes
};

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

@ -34,10 +34,6 @@ EffectMask::PrintInfo(std::stringstream& aStream, const char* aPrefix)
aStream << nsPrintfCString("EffectMask (0x%p)", this).get();
AppendToString(aStream, mSize, " [size=", "]");
AppendToString(aStream, mMaskTransform, " [mask-transform=", "]");
if (mIs3D) {
aStream << " [is-3d]";
}
}
void

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

@ -85,7 +85,6 @@ struct EffectMask : public Effect
const gfx::Matrix4x4 &aMaskTransform)
: Effect(EffectTypes::MASK)
, mMaskTexture(aMaskTexture)
, mIs3D(false)
, mSize(aSize)
, mMaskTransform(aMaskTransform)
{}
@ -93,7 +92,6 @@ struct EffectMask : public Effect
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
TextureSource* mMaskTexture;
bool mIs3D;
gfx::IntSize mSize;
gfx::Matrix4x4 mMaskTransform;
};

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

@ -1202,7 +1202,6 @@ SenderHelper::SendMaskEffect(GLContext* aGLContext,
// Expose packet creation here, so we could dump secondary mask effect attributes.
auto packet = MakeUnique<layerscope::Packet>();
TexturePacket::EffectMask* mask = packet->mutable_texture()->mutable_mask();
mask->set_mis3d(aEffect->mIs3D);
mask->mutable_msize()->set_w(aEffect->mSize.width);
mask->mutable_msize()->set_h(aEffect->mSize.height);
auto element = reinterpret_cast<const Float *>(&(aEffect->mMaskTransform));

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

@ -148,8 +148,7 @@ CompositableHost::SetCompositor(Compositor* aCompositor)
bool
CompositableHost::AddMaskEffect(EffectChain& aEffects,
const gfx::Matrix4x4& aTransform,
bool aIs3D)
const gfx::Matrix4x4& aTransform)
{
CompositableTextureSourceRef source;
RefPtr<TextureHost> host = GetAsTextureHost();
@ -174,7 +173,6 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
RefPtr<EffectMask> effect = new EffectMask(source,
source->GetSize(),
aTransform);
effect->mIs3D = aIs3D;
aEffects.mSecondaryEffects[EffectTypes::MASK] = effect;
return true;
}

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

@ -121,8 +121,7 @@ public:
* @return true if the effect was added, false otherwise.
*/
bool AddMaskEffect(EffectChain& aEffects,
const gfx::Matrix4x4& aTransform,
bool aIs3D = false);
const gfx::Matrix4x4& aTransform);
void RemoveMaskEffect();

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

@ -1466,8 +1466,7 @@ LayerManagerComposite::CreateRefLayerComposite()
}
LayerManagerComposite::AutoAddMaskEffect::AutoAddMaskEffect(Layer* aMaskLayer,
EffectChain& aEffects,
bool aIs3D)
EffectChain& aEffects)
: mCompositable(nullptr), mFailed(false)
{
if (!aMaskLayer) {
@ -1481,7 +1480,7 @@ LayerManagerComposite::AutoAddMaskEffect::AutoAddMaskEffect(Layer* aMaskLayer,
return;
}
if (!mCompositable->AddMaskEffect(aEffects, aMaskLayer->GetEffectiveTransform(), aIs3D)) {
if (!mCompositable->AddMaskEffect(aEffects, aMaskLayer->GetEffectiveTransform())) {
mCompositable = nullptr;
mFailed = true;
}

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

@ -188,8 +188,7 @@ public:
{
public:
AutoAddMaskEffect(Layer* aMaskLayer,
EffectChain& aEffect,
bool aIs3D = false);
EffectChain& aEffect);
~AutoAddMaskEffect();
bool Failed() const { return mFailed; }
@ -582,16 +581,11 @@ RenderWithAllMasks(Layer* aLayer, Compositor* aCompositor,
// no mask layers at all
}
bool firstMaskIs3D = false;
if (ContainerLayer* container = aLayer->AsContainerLayer()) {
firstMaskIs3D = !container->GetTransform().CanDraw2D();
}
if (maskLayerCount <= 1) {
// This is the common case. Render in one pass and return.
EffectChain effectChain(aLayer);
LayerManagerComposite::AutoAddMaskEffect
autoMaskEffect(firstMask, effectChain, firstMaskIs3D);
autoMaskEffect(firstMask, effectChain);
aLayer->AsLayerComposite()->AddBlendModeEffect(effectChain);
aRenderCallback(effectChain, gfx::Rect(aClipRect));
return;
@ -630,7 +624,7 @@ RenderWithAllMasks(Layer* aLayer, Compositor* aCompositor,
{
EffectChain firstEffectChain(aLayer);
LayerManagerComposite::AutoAddMaskEffect
firstMaskEffect(firstMask, firstEffectChain, firstMaskIs3D);
firstMaskEffect(firstMask, firstEffectChain);
aRenderCallback(firstEffectChain, gfx::Rect(aClipRect - surfaceRect.TopLeft()));
// firstTarget now contains the transformed source with the first mask and
// opacity already applied.

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

@ -14,8 +14,7 @@
// These must be in the same order as the Mask enum.
#define PS_MASK_NONE 0
#define PS_MASK_2D 1
#define PS_MASK_3D 2
#define PS_MASK 1
// These must be in the same order as CompositionOp.
#define PS_BLEND_MULTIPLY 0
@ -50,8 +49,7 @@ BlendOpToShaderConstant(gfx::CompositionOp aOp) {
namespace {
static inline void BlendShaderConstantAsserts() {
static_assert(PS_MASK_NONE == int(mozilla::layers::MaskType::MaskNone), "shader constant is out of sync");
static_assert(PS_MASK_2D == int(mozilla::layers::MaskType::Mask2d), "shader constant is out of sync");
static_assert(PS_MASK_3D == int(mozilla::layers::MaskType::Mask3d), "shader constant is out of sync");
static_assert(PS_MASK == int(mozilla::layers::MaskType::Mask), "shader constant is out of sync");
static_assert(int(mozilla::gfx::CompositionOp::OP_LUMINOSITY) - int(mozilla::gfx::CompositionOp::OP_MULTIPLY) == 14,
"shader constants are out of sync");
}

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

@ -901,12 +901,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
MaskType maskType = MaskType::MaskNone;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
if (aTransform.Is2D()) {
maskType = MaskType::Mask2d;
} else {
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EffectTypes::RGB);
maskType = MaskType::Mask3d;
}
maskType = MaskType::Mask;
EffectMask* maskEffect =
static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
@ -1490,8 +1485,7 @@ DeviceAttachmentsD3D11::InitBlendShaders()
{
if (!mVSQuadBlendShader[MaskType::MaskNone]) {
InitVertexShader(sLayerQuadBlendVS, mVSQuadBlendShader, MaskType::MaskNone);
InitVertexShader(sLayerQuadBlendMaskVS, mVSQuadBlendShader, MaskType::Mask2d);
InitVertexShader(sLayerQuadBlendMask3DVS, mVSQuadBlendShader, MaskType::Mask3d);
InitVertexShader(sLayerQuadBlendMaskVS, mVSQuadBlendShader, MaskType::Mask);
}
if (!mBlendShader[MaskType::MaskNone]) {
InitPixelShader(sBlendShader, mBlendShader, MaskType::MaskNone);
@ -1503,21 +1497,19 @@ bool
DeviceAttachmentsD3D11::CreateShaders()
{
InitVertexShader(sLayerQuadVS, mVSQuadShader, MaskType::MaskNone);
InitVertexShader(sLayerQuadMaskVS, mVSQuadShader, MaskType::Mask2d);
InitVertexShader(sLayerQuadMask3DVS, mVSQuadShader, MaskType::Mask3d);
InitVertexShader(sLayerQuadMaskVS, mVSQuadShader, MaskType::Mask);
InitPixelShader(sSolidColorShader, mSolidColorShader, MaskType::MaskNone);
InitPixelShader(sSolidColorShaderMask, mSolidColorShader, MaskType::Mask2d);
InitPixelShader(sSolidColorShaderMask, mSolidColorShader, MaskType::Mask);
InitPixelShader(sRGBShader, mRGBShader, MaskType::MaskNone);
InitPixelShader(sRGBShaderMask, mRGBShader, MaskType::Mask2d);
InitPixelShader(sRGBShaderMask, mRGBShader, MaskType::Mask);
InitPixelShader(sRGBAShader, mRGBAShader, MaskType::MaskNone);
InitPixelShader(sRGBAShaderMask, mRGBAShader, MaskType::Mask2d);
InitPixelShader(sRGBAShaderMask3D, mRGBAShader, MaskType::Mask3d);
InitPixelShader(sRGBAShaderMask, mRGBAShader, MaskType::Mask);
InitPixelShader(sYCbCrShader, mYCbCrShader, MaskType::MaskNone);
InitPixelShader(sYCbCrShaderMask, mYCbCrShader, MaskType::Mask2d);
InitPixelShader(sYCbCrShaderMask, mYCbCrShader, MaskType::Mask);
if (gfxPrefs::ComponentAlphaEnabled()) {
InitPixelShader(sComponentAlphaShader, mComponentAlphaShader, MaskType::MaskNone);
InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, MaskType::Mask2d);
InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, MaskType::Mask);
}
InitVertexShader(sOculus050VRDistortionVS, getter_AddRefs(mVRDistortionVS[VRHMDType::Oculus050]));

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

@ -47,12 +47,6 @@ struct VS_OUTPUT {
};
struct VS_MASK_OUTPUT {
float4 vPosition : SV_Position;
float2 vTexCoords : TEXCOORD0;
float2 vMaskCoords : TEXCOORD1;
};
struct VS_MASK_3D_OUTPUT {
float4 vPosition : SV_Position;
float2 vTexCoords : TEXCOORD0;
float3 vMaskCoords : TEXCOORD1;
@ -153,23 +147,6 @@ VS_MASK_OUTPUT LayerQuadMaskVS(const VS_INPUT aVertex)
// calculate the position on the mask texture
outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z;
outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w;
outp.vTexCoords = TexCoords(aVertex.vPosition.xy);
return outp;
}
VS_MASK_3D_OUTPUT LayerQuadMask3DVS(const VS_INPUT aVertex)
{
VS_MASK_3D_OUTPUT outp;
float4 position = TransformedPosition(aVertex.vPosition);
outp.vPosition = VertexPosition(position);
// calculate the position on the mask texture
position.xyz /= position.w;
outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z;
outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w;
// We use the w coord to do non-perspective correct interpolation:
// the quad might be transformed in 3D, in which case it will have some
// perspective. The graphics card will do perspective-correct interpolation
@ -187,16 +164,9 @@ VS_MASK_3D_OUTPUT LayerQuadMask3DVS(const VS_INPUT aVertex)
}
float4 RGBAShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
{
float2 maskCoords = aVertex.vMaskCoords;
float mask = tMask.Sample(sSampler, maskCoords).r;
return tRGB.Sample(sSampler, aVertex.vTexCoords) * fLayerOpacity * mask;
}
float4 RGBAShaderMask3D(const VS_MASK_3D_OUTPUT aVertex) : SV_Target
{
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tMask.Sample(LayerTextureSamplerLinear, maskCoords).r;
float mask = tMask.Sample(sSampler, maskCoords).r;
return tRGB.Sample(sSampler, aVertex.vTexCoords) * fLayerOpacity * mask;
}
@ -206,7 +176,7 @@ float4 RGBShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
result = tRGB.Sample(sSampler, aVertex.vTexCoords) * fLayerOpacity;
result.a = fLayerOpacity;
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tMask.Sample(sSampler, maskCoords).r;
return result * mask;
}
@ -240,7 +210,7 @@ float4 CalculateYCbCrColor(const float2 aTexCoords)
float4 YCbCrShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
{
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tMask.Sample(sSampler, maskCoords).r;
return CalculateYCbCrColor(aVertex.vTexCoords) * fLayerOpacity * mask;
@ -254,7 +224,7 @@ PS_OUTPUT ComponentAlphaShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
result.vAlpha = 1.0 - tRGBWhite.Sample(sSampler, aVertex.vTexCoords) + result.vSrc;
result.vSrc.a = result.vAlpha.g;
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tMask.Sample(sSampler, maskCoords).r;
result.vSrc *= fLayerOpacity * mask;
result.vAlpha *= fLayerOpacity * mask;
@ -264,7 +234,7 @@ PS_OUTPUT ComponentAlphaShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
float4 SolidColorShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
{
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tMask.Sample(sSampler, maskCoords).r;
return fLayerColor * mask;
}
@ -325,18 +295,6 @@ VS_BLEND_OUTPUT LayerQuadBlendMaskVS(const VS_INPUT aVertex)
{
VS_MASK_OUTPUT v = LayerQuadMaskVS(aVertex);
VS_BLEND_OUTPUT o;
o.vPosition = v.vPosition;
o.vTexCoords = v.vTexCoords;
o.vMaskCoords = float3(v.vMaskCoords, 0);
o.vBackdropCoords = BackdropPosition(v.vPosition);
return o;
}
VS_BLEND_OUTPUT LayerQuadBlendMask3DVS(const VS_INPUT aVertex)
{
VS_MASK_3D_OUTPUT v = LayerQuadMask3DVS(aVertex);
VS_BLEND_OUTPUT o;
o.vPosition = v.vPosition;
o.vTexCoords = v.vTexCoords;
@ -367,7 +325,7 @@ float4 ComputeBlendSourceColor(const VS_BLEND_OUTPUT aVertex)
VS_MASK_OUTPUT tmp;
tmp.vPosition = aVertex.vPosition;
tmp.vTexCoords = aVertex.vTexCoords;
tmp.vMaskCoords = aVertex.vMaskCoords.xy;
tmp.vMaskCoords = aVertex.vMaskCoords;
if (iBlendConfig.x == PS_LAYER_RGB) {
return RGBShaderMask(tmp);
@ -377,13 +335,6 @@ float4 ComputeBlendSourceColor(const VS_BLEND_OUTPUT aVertex)
return YCbCrShaderMask(tmp);
}
return SolidColorShaderMask(tmp);
} else if (iBlendConfig.y == PS_MASK_3D) {
// The only Mask 3D shader is RGBA.
VS_MASK_3D_OUTPUT tmp;
tmp.vPosition = aVertex.vPosition;
tmp.vTexCoords = aVertex.vTexCoords;
tmp.vMaskCoords = aVertex.vMaskCoords;
return RGBAShaderMask3D(tmp);
}
return float4(0.0, 0.0, 0.0, 1.0);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,6 +1,6 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//
// Buffer Definitions:
@ -16,9 +16,9 @@
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals cbuffer NA NA 0 1
// Name Type Format Dim HLSL Bind Count
// ------------------------------ ---------- ------- ----------- -------------- ------
// $Globals cbuffer NA NA cb0 1
//
//
//
@ -80,7 +80,7 @@
// approximately 10 instruction slots used
vs_4_0
dcl_constantbuffer cb0[2], immediateIndexed
dcl_constantbuffer CB0[2], immediateIndexed
dcl_input v0.xy
dcl_input v1.xy
dcl_input v2.xy
@ -106,10 +106,10 @@ ret
const BYTE Oculus050VRDistortionVS[] =
{
68, 88, 66, 67, 3, 61,
196, 122, 10, 53, 44, 234,
18, 242, 195, 238, 42, 90,
72, 193, 1, 0, 0, 0,
68, 88, 66, 67, 92, 195,
173, 230, 45, 84, 78, 45,
143, 175, 88, 53, 65, 235,
243, 174, 1, 0, 0, 0,
244, 5, 0, 0, 6, 0,
0, 0, 56, 0, 0, 0,
108, 1, 0, 0, 44, 3,
@ -303,9 +303,9 @@ const BYTE Oculus050VRDistortionVS[] =
83, 76, 32, 83, 104, 97,
100, 101, 114, 32, 67, 111,
109, 112, 105, 108, 101, 114,
32, 54, 46, 51, 46, 57,
54, 48, 48, 46, 49, 54,
51, 56, 52, 0, 171, 171,
32, 49, 48, 46, 48, 46,
49, 48, 48, 49, 49, 46,
49, 54, 51, 56, 52, 0,
73, 83, 71, 78, 152, 0,
0, 0, 5, 0, 0, 0,
8, 0, 0, 0, 128, 0,
@ -364,15 +364,15 @@ const BYTE Oculus050VRDistortionVS[] =
ShaderBytes sOculus050VRDistortionVS = { Oculus050VRDistortionVS, sizeof(Oculus050VRDistortionVS) };
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// Linear sampler NA NA 0 1
// Texture texture float4 2d 0 1
// Name Type Format Dim HLSL Bind Count
// ------------------------------ ---------- ------- ----------- -------------- ------
// Linear sampler NA NA s0 1
// Texture texture float4 2d t0 1
//
//
//
@ -442,10 +442,10 @@ ret
const BYTE Oculus050VRDistortionPS[] =
{
68, 88, 66, 67, 108, 219,
61, 216, 27, 0, 27, 222,
242, 132, 183, 21, 166, 141,
130, 39, 1, 0, 0, 0,
68, 88, 66, 67, 17, 210,
217, 234, 219, 61, 77, 84,
3, 36, 81, 127, 138, 35,
252, 53, 1, 0, 0, 0,
128, 4, 0, 0, 6, 0,
0, 0, 56, 0, 0, 0,
60, 1, 0, 0, 132, 2,
@ -595,9 +595,9 @@ const BYTE Oculus050VRDistortionPS[] =
76, 32, 83, 104, 97, 100,
101, 114, 32, 67, 111, 109,
112, 105, 108, 101, 114, 32,
54, 46, 51, 46, 57, 54,
48, 48, 46, 49, 54, 51,
56, 52, 0, 171, 171, 171,
49, 48, 46, 48, 46, 49,
48, 48, 49, 49, 46, 49,
54, 51, 56, 52, 0, 171,
73, 83, 71, 78, 156, 0,
0, 0, 5, 0, 0, 0,
8, 0, 0, 0, 128, 0,

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

@ -36,18 +36,15 @@ makeShaderPS RGBAShader
makeShaderPS ComponentAlphaShader
makeShaderPS YCbCrShader
makeShaderVS LayerQuadMaskVS
makeShaderVS LayerQuadMask3DVS
makeShaderPS SolidColorShaderMask
makeShaderPS RGBShaderMask
makeShaderPS RGBAShaderMask
makeShaderPS RGBAShaderMask3D
makeShaderPS YCbCrShaderMask
makeShaderPS ComponentAlphaShaderMask
# Mix-blend shaders
makeShaderVS LayerQuadBlendVS
makeShaderVS LayerQuadBlendMaskVS
makeShaderVS LayerQuadBlendMask3DVS
makeShaderPS BlendShader
SRC=CompositorD3D11VR.hlsl

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

@ -292,11 +292,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
MaskType maskType = MaskType::MaskNone;
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
if (aTransform.Is2D()) {
maskType = MaskType::Mask2d;
} else {
maskType = MaskType::Mask3d;
}
maskType = MaskType::Mask;
}
gfx::Rect backdropDest;

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

@ -396,13 +396,6 @@ DeviceManagerD3D9::Init()
gfxCriticalError() << failCreateShaderMsg << "LayerQuadVSMask: " << gfx::hexa(hr);
return false;
}
hr = mDevice->CreateVertexShader((DWORD*)LayerQuadVSMask3D,
getter_AddRefs(mLayerVSMask3D));
if (FAILED(hr)) {
gfxCriticalError() << failCreateShaderMsg << "LayerQuadVSMask3D: " << gfx::hexa(hr);
return false;
}
hr = mDevice->CreatePixelShader((DWORD*)RGBShaderPSMask,
getter_AddRefs(mRGBPSMask));
@ -420,14 +413,6 @@ DeviceManagerD3D9::Init()
return false;
}
hr = mDevice->CreatePixelShader((DWORD*)RGBAShaderPSMask3D,
getter_AddRefs(mRGBAPSMask3D));
if (FAILED(hr)) {
gfxCriticalError() << failCreateShaderMsg << "RGBAShaderPSMask3D: " << gfx::hexa(hr);
return false;
}
hr = mDevice->CreatePixelShader((DWORD*)ComponentPass1ShaderPSMask,
getter_AddRefs(mComponentPass1PSMask));
@ -597,13 +582,8 @@ DeviceManagerD3D9::SetShaderMode(ShaderMode aMode, MaskType aMaskType)
maskTexRegister = 1;
break;
case RGBALAYER:
if (aMaskType == MaskType::Mask2d) {
mDevice->SetVertexShader(mLayerVSMask);
mDevice->SetPixelShader(mRGBAPSMask);
} else {
mDevice->SetVertexShader(mLayerVSMask3D);
mDevice->SetPixelShader(mRGBAPSMask3D);
}
mDevice->SetVertexShader(mLayerVSMask);
mDevice->SetPixelShader(mRGBAPSMask);
maskTexRegister = 1;
break;
case COMPONENTLAYERPASS1:

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

@ -272,10 +272,8 @@ private:
/* As above, but using a mask layer */
RefPtr<IDirect3DVertexShader9> mLayerVSMask;
RefPtr<IDirect3DVertexShader9> mLayerVSMask3D;
RefPtr<IDirect3DPixelShader9> mRGBPSMask;
RefPtr<IDirect3DPixelShader9> mRGBAPSMask;
RefPtr<IDirect3DPixelShader9> mRGBAPSMask3D;
RefPtr<IDirect3DPixelShader9> mComponentPass1PSMask;
RefPtr<IDirect3DPixelShader9> mComponentPass2PSMask;
RefPtr<IDirect3DPixelShader9> mYCbCrPSMask;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -29,12 +29,6 @@ struct VS_OUTPUT {
};
struct VS_OUTPUT_MASK {
float4 vPosition : POSITION;
float2 vTexCoords : TEXCOORD0;
float2 vMaskCoords : TEXCOORD1;
};
struct VS_OUTPUT_MASK_3D {
float4 vPosition : POSITION;
float2 vTexCoords : TEXCOORD0;
float3 vMaskCoords : TEXCOORD1;
@ -105,46 +99,7 @@ VS_OUTPUT_MASK LayerQuadVSMask(const VS_INPUT aVertex)
// calculate the position on the mask texture
outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z;
outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w;
size = vTextureCoords.zw;
outp.vTexCoords.x = vTextureCoords.x + aVertex.vPosition.x * size.x;
outp.vTexCoords.y = vTextureCoords.y + aVertex.vPosition.y * size.y;
return outp;
}
VS_OUTPUT_MASK_3D LayerQuadVSMask3D(const VS_INPUT aVertex)
{
VS_OUTPUT_MASK_3D outp;
float4 position = float4(0, 0, 0, 1);
// We use 4 component floats to uniquely describe a rectangle, by the structure
// of x, y, width, height. This allows us to easily generate the 4 corners
// of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the
// stream source for our LayerQuad vertex shader. We do this by doing:
// Xout = x + Xin * width
// Yout = y + Yin * height
float2 size = vLayerQuad.zw;
position.x = vLayerQuad.x + aVertex.vPosition.x * size.x;
position.y = vLayerQuad.y + aVertex.vPosition.y * size.y;
position = mul(mLayerTransform, position);
outp.vPosition.w = position.w;
outp.vPosition.xyz = position.xyz / position.w;
outp.vPosition = outp.vPosition - vRenderTargetOffset;
outp.vPosition.xyz *= outp.vPosition.w;
// adjust our vertices to match d3d9's pixel coordinate system
// which has pixel centers at integer locations
outp.vPosition.xy -= 0.5;
outp.vPosition = mul(mProjection, outp.vPosition);
// calculate the position on the mask texture
position.xyz /= position.w;
outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z;
outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w;
// correct for perspective correct interpolation, see comment in D3D10 shader
// correct for perspective correct interpolation, see comment in D3D11 shader
outp.vMaskCoords.z = 1;
outp.vMaskCoords *= position.w;
@ -211,7 +166,7 @@ float4 ComponentPass1ShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
float4 src = tex2D(s2D, aVertex.vTexCoords);
float4 alphas = 1.0 - tex2D(s2DWhite, aVertex.vTexCoords) + src;
alphas.a = alphas.g;
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tex2D(s2DMask, maskCoords).a;
return alphas * fLayerOpacity * mask;
}
@ -221,19 +176,12 @@ float4 ComponentPass2ShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
float4 src = tex2D(s2D, aVertex.vTexCoords);
float4 alphas = 1.0 - tex2D(s2DWhite, aVertex.vTexCoords) + src;
src.a = alphas.g;
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tex2D(s2DMask, maskCoords).a;
return src * fLayerOpacity * mask;
}
float4 RGBAShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
{
float2 maskCoords = aVertex.vMaskCoords;
float mask = tex2D(s2DMask, maskCoords).a;
return tex2D(s2D, aVertex.vTexCoords) * fLayerOpacity * mask;
}
float4 RGBAShaderMask3D(const VS_OUTPUT_MASK_3D aVertex) : COLOR
{
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tex2D(s2DMask, maskCoords).a;
@ -245,7 +193,7 @@ float4 RGBShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
float4 result;
result = tex2D(s2D, aVertex.vTexCoords);
result.a = 1.0;
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tex2D(s2DMask, maskCoords).a;
return result * fLayerOpacity * mask;
}
@ -274,14 +222,14 @@ float4 YCbCrShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
color.b = yuv.g * 1.16438 + yuv.b * 2.01723;
color.a = 1.0f;
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tex2D(s2DMask, maskCoords).a;
return color * fLayerOpacity * mask;
}
float4 SolidColorShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
{
float2 maskCoords = aVertex.vMaskCoords;
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tex2D(s2DMask, maskCoords).a;
return fLayerColor * mask;
}

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

@ -20,12 +20,8 @@ fxc LayerManagerD3D9Shaders.hlsl -ESolidColorShader -nologo -Tps_2_0 -Fh$tempfil
cat $tempfile >> LayerManagerD3D9Shaders.h
fxc LayerManagerD3D9Shaders.hlsl -ELayerQuadVSMask -nologo -Fh$tempfile -VnLayerQuadVSMask
cat $tempfile >> LayerManagerD3D9Shaders.h
fxc LayerManagerD3D9Shaders.hlsl -ELayerQuadVSMask3D -nologo -Fh$tempfile -VnLayerQuadVSMask3D
cat $tempfile >> LayerManagerD3D9Shaders.h
fxc LayerManagerD3D9Shaders.hlsl -ERGBAShaderMask -nologo -Tps_2_0 -Fh$tempfile -VnRGBAShaderPSMask
cat $tempfile >> LayerManagerD3D9Shaders.h
fxc LayerManagerD3D9Shaders.hlsl -ERGBAShaderMask3D -nologo -Tps_2_0 -Fh$tempfile -VnRGBAShaderPSMask3D
cat $tempfile >> LayerManagerD3D9Shaders.h
fxc LayerManagerD3D9Shaders.hlsl -EComponentPass1ShaderMask -nologo -Tps_2_0 -Fh$tempfile -VnComponentPass1ShaderPSMask
cat $tempfile >> LayerManagerD3D9Shaders.h
fxc LayerManagerD3D9Shaders.hlsl -EComponentPass2ShaderMask -nologo -Tps_2_0 -Fh$tempfile -VnComponentPass2ShaderPSMask

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

@ -879,8 +879,7 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect,
}
}
config.SetColorMatrix(aColorMatrix);
config.SetMask2D(aMask == MaskType::Mask2d);
config.SetMask3D(aMask == MaskType::Mask3d);
config.SetMask(aMask == MaskType::Mask);
config.SetDEAA(aDEAAEnabled);
config.SetCompositionOp(aOp);
return config;
@ -1070,9 +1069,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
maskQuadTransform._41 = float(-bounds.x)/bounds.width;
maskQuadTransform._42 = float(-bounds.y)/bounds.height;
maskType = effectMask->mIs3D
? MaskType::Mask3d
: MaskType::Mask2d;
maskType = MaskType::Mask;
} else {
maskType = MaskType::MaskNone;
}

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

@ -139,15 +139,9 @@ ShaderConfigOGL::SetBlur(bool aEnabled)
}
void
ShaderConfigOGL::SetMask2D(bool aEnabled)
ShaderConfigOGL::SetMask(bool aEnabled)
{
SetFeature(ENABLE_MASK_2D, aEnabled);
}
void
ShaderConfigOGL::SetMask3D(bool aEnabled)
{
SetFeature(ENABLE_MASK_3D, aEnabled);
SetFeature(ENABLE_MASK, aEnabled);
}
void
@ -206,8 +200,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
vs << "varying vec2 vBackdropCoord;" << endl;
}
if (aConfig.mFeatures & ENABLE_MASK_2D ||
aConfig.mFeatures & ENABLE_MASK_3D) {
if (aConfig.mFeatures & ENABLE_MASK) {
vs << "uniform mat4 uMaskTransform;" << endl;
vs << "varying vec3 vMaskCoord;" << endl;
}
@ -232,8 +225,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
vs << " ssPos = uMatrixProj * ssPos;" << endl;
vs << " ssPos.xy = ((ssPos.xy/ssPos.w)*0.5+0.5)*uViewportSize;" << endl;
if (aConfig.mFeatures & ENABLE_MASK_2D ||
aConfig.mFeatures & ENABLE_MASK_3D ||
if (aConfig.mFeatures & ENABLE_MASK ||
!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
vs << " vec4 coordAdjusted;" << endl;
vs << " coordAdjusted.xy = aCoord.xy;" << endl;
@ -278,14 +270,11 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
vs << " vec2 texCoord = aCoord.xy * textureRect.zw + textureRect.xy;" << endl;
vs << " vTexCoord = (uTextureTransform * vec4(texCoord, 0.0, 1.0)).xy;" << endl;
}
if (aConfig.mFeatures & ENABLE_MASK_2D ||
aConfig.mFeatures & ENABLE_MASK_3D) {
if (aConfig.mFeatures & ENABLE_MASK) {
vs << " vMaskCoord.xy = (uMaskTransform * (finalPosition / finalPosition.w)).xy;" << endl;
if (aConfig.mFeatures & ENABLE_MASK_3D) {
// correct for perspective correct interpolation, see comment in D3D10 shader
vs << " vMaskCoord.z = 1.0;" << endl;
vs << " vMaskCoord *= finalPosition.w;" << endl;
}
// correct for perspective correct interpolation, see comment in D3D11 shader
vs << " vMaskCoord.z = 1.0;" << endl;
vs << " vMaskCoord *= finalPosition.w;" << endl;
}
vs << " finalPosition.xy -= uRenderTargetOffset * finalPosition.w;" << endl;
vs << " finalPosition = uMatrixProj * finalPosition;" << endl;
@ -376,8 +365,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
fs << "uniform sampler2D uBackdropTexture;" << endl;
}
if (aConfig.mFeatures & ENABLE_MASK_2D ||
aConfig.mFeatures & ENABLE_MASK_3D) {
if (aConfig.mFeatures & ENABLE_MASK) {
fs << "varying vec3 vMaskCoord;" << endl;
fs << "uniform sampler2D uMaskTexture;" << endl;
}
@ -512,13 +500,10 @@ For [0,1] instead of [0,255], and to 5 places:
fs << " vec4 backdrop = texture2D(uBackdropTexture, vBackdropCoord);" << endl;
fs << " color = mixAndBlend(backdrop, color);" << endl;
}
if (aConfig.mFeatures & ENABLE_MASK_3D) {
if (aConfig.mFeatures & ENABLE_MASK) {
fs << " vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;" << endl;
fs << " COLOR_PRECISION float mask = texture2D(uMaskTexture, maskCoords).r;" << endl;
fs << " color *= mask;" << endl;
} else if (aConfig.mFeatures & ENABLE_MASK_2D) {
fs << " COLOR_PRECISION float mask = texture2D(uMaskTexture, vMaskCoord.xy).r;" << endl;
fs << " color *= mask;" << endl;
} else {
fs << " COLOR_PRECISION float mask = 1.0;" << endl;
fs << " color *= mask;" << endl;
@ -542,8 +527,7 @@ For [0,1] instead of [0,255], and to 5 places:
result.mTextureCount = 1;
}
}
if (aConfig.mFeatures & ENABLE_MASK_2D ||
aConfig.mFeatures & ENABLE_MASK_3D) {
if (aConfig.mFeatures & ENABLE_MASK) {
result.mTextureCount = 1;
}
if (BlendOpIsMixBlendMode(blendOp)) {

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

@ -37,10 +37,9 @@ enum ShaderFeatures {
ENABLE_OPACITY=0x100,
ENABLE_BLUR=0x200,
ENABLE_COLOR_MATRIX=0x400,
ENABLE_MASK_2D=0x800,
ENABLE_MASK_3D=0x1000,
ENABLE_NO_PREMUL_ALPHA=0x2000,
ENABLE_DEAA=0x4000
ENABLE_MASK=0x800,
ENABLE_NO_PREMUL_ALPHA=0x1000,
ENABLE_DEAA=0x2000
};
class KnownUniform {
@ -223,8 +222,7 @@ public:
void SetComponentAlpha(bool aEnabled);
void SetColorMatrix(bool aEnabled);
void SetBlur(bool aEnabled);
void SetMask2D(bool aEnabled);
void SetMask3D(bool aEnabled);
void SetMask(bool aEnabled);
void SetDEAA(bool aEnabled);
void SetCompositionOp(gfx::CompositionOp aOp);
void SetNoPremultipliedAlpha();