Bug 648484, part B: Implement shadowable layer goop for D3D10, just enough to allow sending a window buffer to the compositor. r=Bas
authorChris Jones <jones.chris.g@gmail.com>
Wed, 13 Jul 2011 22:43:43 -0700
changeset 72812 53225816d90a4be383a205a3c09a45e5f1c5d9e4
parent 72811 098a1ccb8757eedf0caec48fd323b9ed5ea0ea4b
child 72813 ecbf6db5d91204d225bf2a8e227cce404bc1f2c2
push id20772
push usereakhgari@mozilla.com
push dateThu, 14 Jul 2011 16:20:50 +0000
treeherdermozilla-central@89b5fccb0514 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs648484
milestone8.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
Bug 648484, part B: Implement shadowable layer goop for D3D10, just enough to allow sending a window buffer to the compositor. r=Bas
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.h
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * ***** 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/
  *
@@ -46,16 +46,17 @@
 #include "dxgi.h"
 
 #include "ContainerLayerD3D10.h"
 #include "ThebesLayerD3D10.h"
 #include "ColorLayerD3D10.h"
 #include "CanvasLayerD3D10.h"
 #include "ReadbackLayerD3D10.h"
 #include "ImageLayerD3D10.h"
+#include "mozilla/layers/PLayerChild.h"
 
 #include "../d3d9/Nv3DVUtils.h"
 
 #include "gfxCrashReporterUtils.h"
 
 using namespace std;
 using namespace mozilla::gfx;
 
@@ -766,10 +767,47 @@ LayerManagerD3D10::ReportFailure(const n
   gfx::LogFailure(msg);
 }
 
 LayerD3D10::LayerD3D10(LayerManagerD3D10 *aManager)
   : mD3DManager(aManager)
 {
 }
 
+WindowLayer::WindowLayer(LayerManagerD3D10* aManager)
+  : ThebesLayer(aManager, nsnull)
+{
+ }
+
+WindowLayer::~WindowLayer()
+{
+  PLayerChild::Send__delete__(GetShadow());
+}
+
+DummyRoot::DummyRoot(LayerManagerD3D10* aManager)
+  : ContainerLayer(aManager, nsnull)
+{
+}
+
+DummyRoot::~DummyRoot()
+{
+  RemoveChild(nsnull);
+  PLayerChild::Send__delete__(GetShadow());
+}
+
+void
+DummyRoot::InsertAfter(Layer* aLayer, Layer* aNull)
+{
+  NS_ABORT_IF_FALSE(!mFirstChild && !aNull,
+                    "Expect to append one child, once");
+  mFirstChild = nsRefPtr<Layer>(aLayer).forget().get();
+}
+
+void
+DummyRoot::RemoveChild(Layer* aNull)
+{
+  NS_ABORT_IF_FALSE(!aNull, "Unused argument should be null");
+  NS_IF_RELEASE(mFirstChild);
+}
+
+
 }
 }
--- a/gfx/layers/d3d10/LayerManagerD3D10.h
+++ b/gfx/layers/d3d10/LayerManagerD3D10.h
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * ***** 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/
  *
@@ -33,30 +33,32 @@
  * 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 GFX_LAYERMANAGERD3D10_H
 #define GFX_LAYERMANAGERD3D10_H
 
+#include "mozilla/layers/PLayers.h"
 #include "mozilla/layers/ShadowLayers.h"
 #include "Layers.h"
 
 #include <windows.h>
 #include <d3d10_1.h>
 
 #include "gfxContext.h"
 #include "nsIWidget.h"
 
 #include "ReadbackManagerD3D10.h"
 
 namespace mozilla {
 namespace layers {
 
+class DummyRoot;
 class Nv3DVUtils;
 
 /**
  * This structure is used to pass rectangles to our shader constant. We can use
  * this for passing rectangular areas to SetVertexShaderConstant. In the format
  * of a 4 component float(x,y,width,height). Our vertex shader can then use
  * this to construct rectangular positions from the 0,0-1,1 quad that we source
  * it with.
@@ -290,12 +292,50 @@ public:
     effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
     effect()->GetVariableByName("fLayerOpacity")->AsScalar()->SetFloat(layer->GetEffectiveOpacity());
   }
 
 protected:
   LayerManagerD3D10 *mD3DManager;
 };
 
+/**
+ * WindowLayer is a simple, special kinds of shadowable layer into
+ * which layer trees are rendered.  It represents something like an OS
+ * window.  It exists only to allow sharing textures with the
+ * compositor while reusing existing shadow-layer machinery.
+ *
+ * WindowLayer being implemented as a thebes layer isn't an important
+ * detail; other layer types could have been used.
+ */
+class WindowLayer : public ThebesLayer, public ShadowableLayer {
+public:
+  WindowLayer(LayerManagerD3D10* aManager);
+  virtual ~WindowLayer();
+
+  void InvalidateRegion(const nsIntRegion&) {}
+  Layer* AsLayer() { return this; }
+
+  void SetShadow(PLayerChild* aChild) { mShadow = aChild; }
+};
+
+/**
+ * DummyRoot is the root of the shadowable layer tree created by
+ * remote content.  It exists only to contain WindowLayers.  It always
+ * has exactly one child WindowLayer.
+ */
+class DummyRoot : public ContainerLayer, public ShadowableLayer {
+public:
+  DummyRoot(LayerManagerD3D10* aManager);
+  virtual ~DummyRoot();
+
+  void ComputeEffectiveTransforms(const gfx3DMatrix&) {}
+  void InsertAfter(Layer*, Layer*);
+  void RemoveChild(Layer*);
+  Layer* AsLayer() { return this; }
+
+  void SetShadow(PLayerChild* aChild) { mShadow = aChild; }
+};
+
 } /* layers */
 } /* mozilla */
 
 #endif /* GFX_LAYERMANAGERD3D9_H */