Bug 1332268 - Update EffectComponentAlpha texture coordinates when rendering split layers draft
authorMiko Mynttinen <mikokm@gmail.com>
Thu, 19 Jan 2017 21:16:30 +0100
changeset 464173 027e44aedf5bd8d50d5f3532a6ed07b71f3a66b8
parent 464075 aa3e49299a3aa5cb0db570532e3df9e75d30c2d1
child 542882 615380130705e4179da1aec18650260823bcc5d8
push id42303
push userbmo:mikokm@gmail.com
push dateFri, 20 Jan 2017 17:21:37 +0000
bugs1332268
milestone53.0a1
Bug 1332268 - Update EffectComponentAlpha texture coordinates when rendering split layers MozReview-Commit-ID: HFgikDMPB7F
gfx/layers/Compositor.cpp
gfx/layers/Effects.h
layout/reftests/transform-3d/component-alpha-1-ref.html
layout/reftests/transform-3d/component-alpha-1.html
layout/reftests/transform-3d/reftest.list
--- 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