Make shadow layer transformations work.
authorAli Juma <ajuma@mozilla.com>
Thu, 15 Dec 2011 15:20:06 -0500
changeset 92326 ac3508466177cebca2b38377b1d6fa80835a45ef
parent 92325 394b458e856b868aa69995f592aab2d20a71a600
child 92327 17e4dbb62bbeed7a7d54b38f2ecbd95b51d87fdc
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Make shadow layer transformations work.
gfx/layers/Makefile.in
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
gfx/layers/ipc/ShadowLayersHost.h
gfx/layers/ipc/ShadowLayersParent.cpp
gfx/layers/ipc/ShadowLayersParent.h
gfx/layers/opengl/LayerManagerOGL.cpp
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -132,16 +132,17 @@ EXPORTS_NAMESPACES = IPC mozilla/layers
 EXPORTS_IPC = ShadowLayerUtils.h
 EXPORTS_mozilla/layers = \
         Compositor.h \
         CompositorChild.h \
         CompositorParent.h \
         ShadowLayers.h \
         ShadowLayersChild.h \
         ShadowLayersParent.h \
+        ShadowLayersHost.h \
         $(NULL)
 
 CPPSRCS += \
         Compositor.cpp \
         CompositorChild.cpp \
         CompositorParent.cpp \
         ShadowLayers.cpp \
         ShadowLayerChild.cpp \
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -103,17 +103,17 @@ CompositorParent::AllocPLayers(const Lay
     }
 
     void *glContext = layerManager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);
     NativeContext nativeContext = NativeContext((uintptr_t)glContext);
     SendNativeContextCreated(nativeContext);
 
     mLayerManager = layerManager;
 
-    return new ShadowLayersParent(slm);
+    return new ShadowLayersParent(slm, this);
   } else {
     NS_ERROR("Unsupported backend selected for Async Compositor");
     return NULL;
   }
 }
 
 bool
 CompositorParent::DeallocPLayers(PLayersParent* actor)
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -37,31 +37,36 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_layers_CompositorParent_h
 #define mozilla_layers_CompositorParent_h
 
 #include "mozilla/layers/PCompositorParent.h"
 #include "mozilla/layers/PLayersParent.h"
+#include "ShadowLayersHost.h"
 
 class LayerManager;
 
 namespace mozilla {
 namespace layers {
 
-class CompositorParent : public PCompositorParent
+class CompositorParent : public PCompositorParent,
+                         public ShadowLayersHost
 {
   NS_INLINE_DECL_REFCOUNTING(CompositorParent)
 public:
   CompositorParent();
   virtual ~CompositorParent();
 
   bool AnswerInit();
 
+  virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() { return NULL; }
+  virtual CompositorParent* GetCompositorParent() { return this; }
+
 protected:
   virtual PLayersParent* AllocPLayers(const LayersBackend &backend, const WidgetDescriptor &widget);
 
   virtual bool DeallocPLayers(PLayersParent* aLayers);
 
 private:
   void Composite();
 
new file mode 100644
--- /dev/null
+++ b/gfx/layers/ipc/ShadowLayersHost.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set sw=4 ts=8 et tw=80 : */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Content App.
+ *
+ * The Initial Developer of the Original Code is
+ *   The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Ali Juma <ajuma@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef mozilla_layers_ShadowLayersHost_h
+#define mozilla_layers_ShadowLayersHost_h
+
+namespace mozilla {
+
+namespace layout {
+class RenderFrameParent;
+}
+
+namespace layers {
+
+class CompositorParent;
+
+class ShadowLayersHost
+{
+NS_INLINE_DECL_REFCOUNTING(ShadowLayersHost)
+
+public:
+  virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() = 0;
+  virtual CompositorParent* GetCompositorParent() = 0;
+};
+
+} // layers
+} // mozilla
+
+#endif // mozilla_layers_ShadowLayersHost_h
--- a/gfx/layers/ipc/ShadowLayersParent.cpp
+++ b/gfx/layers/ipc/ShadowLayersParent.cpp
@@ -116,21 +116,22 @@ ShadowContainer(const OpRemoveChild& op)
 static ShadowLayerParent*
 ShadowChild(const OpRemoveChild& op)
 {
   return cast(op.childLayerParent());
 }
 
 //--------------------------------------------------
 // ShadowLayersParent
-ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager)
+ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager, ShadowLayersHost* aHost)
   : mDestroyed(false)
 {
   MOZ_COUNT_CTOR(ShadowLayersParent);
   mLayerManager = aManager;
+  mHost = aHost;
 }
 
 ShadowLayersParent::~ShadowLayersParent()
 {
   MOZ_COUNT_DTOR(ShadowLayersParent);
 }
 
 void
@@ -214,16 +215,21 @@ ShadowLayersParent::RecvUpdate(const Inf
 
       const CommonLayerAttributes& common = attrs.common();
       layer->SetVisibleRegion(common.visibleRegion());
       layer->SetContentFlags(common.contentFlags());
       layer->SetOpacity(common.opacity());
       layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
       layer->SetTransform(common.transform());
       layer->SetTileSourceRect(common.useTileSourceRect() ? &common.tileSourceRect() : NULL);
+      if (mHost->GetCompositorParent()) {
+        layer->AsShadowLayer()->SetShadowTransform(common.transform());
+        layer->AsShadowLayer()->SetShadowVisibleRegion(common.visibleRegion());
+        layer->AsShadowLayer()->SetShadowClipRect(layer->GetClipRect());
+      }
       static bool fixedPositionLayersEnabled = getenv("MOZ_ENABLE_FIXED_POSITION_LAYERS") != 0;
       if (fixedPositionLayersEnabled) {
         layer->SetIsFixedPosition(common.isFixedPosition());
       }
 
       typedef SpecificLayerAttributes Specific;
       const SpecificLayerAttributes& specific = attrs.specific();
       switch (specific.type()) {
@@ -401,19 +407,17 @@ ShadowLayersParent::DeallocPLayer(PLayer
 {
   delete actor;
   return true;
 }
 
 RenderFrameParent*
 ShadowLayersParent::Frame()
 {
-  // Fix me, gives: error: ‘Manager’ was not declared in this scope
-  //return static_cast<RenderFrameParent*>(Manager());
-  return NULL;
+  return mHost->GetRenderFrameParent();
 }
 
 void
 ShadowLayersParent::DestroySharedSurface(gfxSharedImageSurface* aSurface)
 {
   layer_manager()->DestroySharedSurface(aSurface, this);
 }
 
--- a/gfx/layers/ipc/ShadowLayersParent.h
+++ b/gfx/layers/ipc/ShadowLayersParent.h
@@ -38,16 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_layers_ShadowLayersParent_h
 #define mozilla_layers_ShadowLayersParent_h
 
 #include "mozilla/layers/PLayersParent.h"
 #include "ShadowLayers.h"
+#include "ShadowLayersHost.h"
 
 namespace mozilla {
 
 namespace layout {
 class RenderFrameParent;
 }
 
 namespace layers {
@@ -58,17 +59,17 @@ class ShadowLayerManager;
 class ShadowLayersParent : public PLayersParent,
                            public ISurfaceDeAllocator
 {
   typedef mozilla::layout::RenderFrameParent RenderFrameParent;
   typedef InfallibleTArray<Edit> EditArray;
   typedef InfallibleTArray<EditReply> EditReplyArray;
 
 public:
-  ShadowLayersParent(ShadowLayerManager* aManager);
+  ShadowLayersParent(ShadowLayerManager* aManager, ShadowLayersHost* aHost);
   ~ShadowLayersParent();
 
   void Destroy();
 
   ShadowLayerManager* layer_manager() const { return mLayerManager; }
 
   ContainerLayer* GetRoot() const { return mRoot; }
 
@@ -81,16 +82,17 @@ protected:
 
   NS_OVERRIDE virtual PLayerParent* AllocPLayer();
   NS_OVERRIDE virtual bool DeallocPLayer(PLayerParent* actor);
 
 private:
   RenderFrameParent* Frame();
 
   nsRefPtr<ShadowLayerManager> mLayerManager;
+  nsRefPtr<ShadowLayersHost> mHost;
   // Hold the root because it might be grafted under various
   // containers in the "real" layer tree
   nsRefPtr<ContainerLayer> mRoot;
   // When the widget/frame/browser stuff in this process begins its
   // destruction process, we need to Disconnect() all the currently
   // live shadow layers, because some of them might be orphaned from
   // the layer tree.  This happens in Destroy() above.  After we
   // Destroy() ourself, there's a window in which that information
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -795,31 +795,31 @@ LayerManagerOGL::Render()
   } else {
     mGLContext->fScissor(0, 0, width, height);
   }
 
   //mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
 
   mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
   mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
-
+/*
   ShadowLayer *shadow = RootLayer()->GetLayer()->AsShadowLayer();
   if (shadow) {
     shadow->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
     for (Layer* child = RootLayer()->GetLayer()->GetFirstChild(); child; child = child->GetNextSibling()) {
       for (Layer* child2 = child->GetFirstChild(); child2; child2 = child2->GetNextSibling()) {
       for (Layer* child3 = child2->GetFirstChild(); child3; child3 = child3->GetNextSibling()) {
        child3->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
       }
        child2->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
       }
      child->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
     }
   }
-
+*/
   // Render our layers.
   RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO,
                            nsIntPoint(0, 0));
                            
   mWidget->DrawOver(this, rect);
 
   if (mTarget) {
     CopyToTarget();
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -643,17 +643,17 @@ RenderFrameParent::AllocPLayers(LayerMan
   }
   LayerManager* lm = GetLayerManager();
   ShadowLayerManager* slm = lm->AsShadowManager();
   if (!slm) {
     *aBackendType = LayerManager::LAYERS_NONE;
      return nsnull;
   }
   *aBackendType = lm->GetBackendType();
-  return new ShadowLayersParent(slm);
+  return new ShadowLayersParent(slm, this);
 }
 
 bool
 RenderFrameParent::DeallocPLayers(PLayersParent* aLayers)
 {
   delete aLayers;
   return true;
 }
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -37,16 +37,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_layout_RenderFrameParent_h
 #define mozilla_layout_RenderFrameParent_h
 
 #include "mozilla/layout/PRenderFrameParent.h"
+#include "mozilla/layers/ShadowLayersHost.h"
 
 #include <map>
 #include "nsDisplayList.h"
 #include "Layers.h"
 
 class nsContentView;
 class nsFrameLoader;
 class nsSubDocumentFrame;
@@ -54,17 +55,18 @@ class nsSubDocumentFrame;
 namespace mozilla {
 
 namespace layers {
 class ShadowLayersParent;
 }
 
 namespace layout {
 
-class RenderFrameParent : public PRenderFrameParent
+class RenderFrameParent : public PRenderFrameParent,
+                          public mozilla::layers::ShadowLayersHost
 {
   typedef mozilla::layers::FrameMetrics FrameMetrics;
   typedef mozilla::layers::ContainerLayer ContainerLayer;
   typedef mozilla::layers::Layer Layer;
   typedef mozilla::layers::LayerManager LayerManager;
   typedef mozilla::layers::ShadowLayersParent ShadowLayersParent;
   typedef FrameMetrics::ViewID ViewID;
 
@@ -95,16 +97,19 @@ public:
                                      nsIFrame* aFrame,
                                      LayerManager* aManager,
                                      const nsIntRect& aVisibleRect);
 
   void OwnerContentChanged(nsIContent* aContent);
 
   void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
 
+  virtual RenderFrameParent* GetRenderFrameParent() { return this; }
+  virtual mozilla::layers::CompositorParent* GetCompositorParent() { return NULL; }
+
 protected:
   NS_OVERRIDE void ActorDestroy(ActorDestroyReason why);
 
   NS_OVERRIDE virtual PLayersParent* AllocPLayers(LayerManager::LayersBackend* aBackendType);
   NS_OVERRIDE virtual bool DeallocPLayers(PLayersParent* aLayers);
 
 private:
   void BuildViewMap();