Bug 1332268 - Update EffectComponentAlpha texture coordinates when rendering split layers
MozReview-Commit-ID: HFgikDMPB7F
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -334,23 +334,20 @@ Compositor::DrawPolygon(const gfx::Polyg
MOZ_ASSERT(intersection.width > 0.0f && intersection.height > 0.0f);
gfx::TexturedTriangle texturedTriangle(Move(triangle));
texturedTriangle.width = aRect.width;
texturedTriangle.height = aRect.height;
// Since the texture was created for non-split geometry, we need to
// update the texture coordinates to account for the split.
- const EffectTypes type = aEffectChain.mPrimaryEffect->mType;
+ TexturedEffect* texturedEffect =
+ aEffectChain.mPrimaryEffect->AsTexturedEffect();
- if (type == EffectTypes::RGB || type == EffectTypes::YCBCR ||
- type == EffectTypes::NV12 || type == EffectTypes::RENDER_TARGET) {
- TexturedEffect* texturedEffect =
- static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
-
+ if (texturedEffect) {
UpdateTextureCoordinates(texturedTriangle, aRect, intersection,
texturedEffect->mTextureCoords);
}
texturedTriangles.AppendElement(Move(texturedTriangle));
}
DrawTriangles(texturedTriangles, aRect, aClipRect, aEffectChain,
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -33,24 +33,27 @@ namespace layers {
* - any way in which rendering can be changed, e.g., applying a mask layer.
*
* During the rendering process, an effect chain is created by the layer being
* rendered and the primary effect is added by the compositable host. Secondary
* effects may be added by the layer or compositable. The effect chain is passed
* to the compositor by the compositable host as a parameter to DrawQuad.
*/
+struct TexturedEffect;
+
struct Effect
{
NS_INLINE_DECL_REFCOUNTING(Effect)
explicit Effect(EffectTypes aType) : mType(aType) {}
EffectTypes mType;
+ virtual TexturedEffect* AsTexturedEffect() { return nullptr; }
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) = 0;
protected:
virtual ~Effect() {}
};
// Render from a texture
struct TexturedEffect : public Effect
@@ -61,16 +64,17 @@ struct TexturedEffect : public Effect
gfx::SamplingFilter aSamplingFilter)
: Effect(aType)
, mTextureCoords(0, 0, 1.0f, 1.0f)
, mTexture(aTexture)
, mPremultiplied(aPremultiplied)
, mSamplingFilter(aSamplingFilter)
{}
+ virtual TexturedEffect* AsTexturedEffect() { return this; }
virtual const char* Name() = 0;
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
gfx::Rect mTextureCoords;
TextureSource* mTexture;
bool mPremultiplied;
gfx::SamplingFilter mSamplingFilter;
LayerRenderState mState;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/component-alpha-1-ref.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<meta charset="utf-8">
+<title>red box</title>
+<style>
+
+#wrapper {
+}
+
+#shape {
+ background-color: red;
+
+ width: 200px;
+ height: 200px;
+}
+</style>
+
+</head>
+<body>
+<div id="wrapper">
+ <div id="shape">foo</div>
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/component-alpha-1.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<meta charset="utf-8">
+<title>red box</title>
+<style>
+
+#wrapper {
+ perspective: 0px;
+}
+
+#shape {
+ background-color: red;
+
+ width: 200px;
+ height: 200px;
+
+ transform: rotateX(0deg);
+}
+</style>
+
+</head>
+<body>
+<div id="wrapper">
+ <div id="shape">foo</div>
+</div>
+
+</body>
+</html>
--- a/layout/reftests/transform-3d/reftest.list
+++ b/layout/reftests/transform-3d/reftest.list
@@ -79,8 +79,9 @@ fuzzy(1,10000) == opacity-preserve3d-3.h
fuzzy(1,10000) == opacity-preserve3d-4.html opacity-preserve3d-4-ref.html
== snap-perspective-1.html snap-perspective-1-ref.html
== mask-layer-1.html mask-layer-ref.html
== mask-layer-2.html mask-layer-ref.html
== mask-layer-3.html mask-layer-ref.html
fails-if(winWidget&&layersGPUAccelerated) == split-intersect1.html split-intersect1-ref.html # Bug 1323791: implement DirectX compositor polygon support
fuzzy(255,150) fails-if(winWidget&&layersGPUAccelerated) == split-intersect2.html split-intersect2-ref.html # Bug 1323791
fuzzy(255,100) fails-if(winWidget&&layersGPUAccelerated) == split-non-ortho1.html split-non-ortho1-ref.html # Bug 1323791
+fuzzy-if(winWidget,150,120) == component-alpha-1.html component-alpha-1-ref.html