diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index e4db66cbe2e0..8172b8528efa 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -26,7 +26,7 @@ * * # Main interfaces and abstractions * - * - Layer, ShadowableLayer and ShadowLayer + * - Layer, ShadowableLayer and LayerComposite * (see Layers.h and ipc/ShadowLayers.h) * - CompositableClient and CompositableHost * (client/CompositableClient.h composite/CompositableHost.h) diff --git a/gfx/layers/CompositorTypes.h b/gfx/layers/CompositorTypes.h index 207183859859..292aa4cc494b 100644 --- a/gfx/layers/CompositorTypes.h +++ b/gfx/layers/CompositorTypes.h @@ -136,6 +136,15 @@ struct TextureInfo } }; +/** + * How a SurfaceDescriptor will be opened. + * + * See ShadowLayerForwarder::OpenDescriptor for example. + */ +enum OpenMode { + OPEN_READ_ONLY, + OPEN_READ_WRITE +}; } // namespace layers } // namespace mozilla diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index ea99e20f1ef3..b3af07bf7f94 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -8,7 +8,7 @@ #include "mozilla/DebugOnly.h" #include "mozilla/layers/PLayerTransaction.h" -#include "mozilla/layers/ShadowLayers.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/Telemetry.h" #include "ImageLayers.h" @@ -460,7 +460,7 @@ Layer::CanUseOpaqueSurface() const nsIntRect* Layer::GetEffectiveClipRect() { - if (ShadowLayer* shadow = AsShadowLayer()) { + if (LayerComposite* shadow = AsLayerComposite()) { return shadow->GetShadowClipRect(); } return GetClipRect(); @@ -469,7 +469,7 @@ Layer::GetEffectiveClipRect() const nsIntRegion& Layer::GetEffectiveVisibleRegion() { - if (ShadowLayer* shadow = AsShadowLayer()) { + if (LayerComposite* shadow = AsLayerComposite()) { return shadow->GetShadowVisibleRegion(); } return GetVisibleRegion(); @@ -640,7 +640,7 @@ const gfx3DMatrix Layer::GetLocalTransform() { gfx3DMatrix transform; - if (ShadowLayer* shadow = AsShadowLayer()) + if (LayerComposite* shadow = AsLayerComposite()) transform = shadow->GetShadowTransform(); else transform = mTransform; @@ -665,7 +665,7 @@ Layer::ApplyPendingUpdatesForThisTransaction() const float Layer::GetLocalOpacity() { - if (ShadowLayer* shadow = AsShadowLayer()) + if (LayerComposite* shadow = AsLayerComposite()) return shadow->GetShadowOpacity(); return mOpacity; } @@ -975,7 +975,7 @@ LayerManager::BeginTabSwitch() #ifdef MOZ_LAYERS_HAVE_LOG -static nsACString& PrintInfo(nsACString& aTo, ShadowLayer* aShadowLayer); +static nsACString& PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite); #ifdef MOZ_DUMP_PAINTING template @@ -1101,7 +1101,7 @@ Layer::PrintInfo(nsACString& aTo, const char* aPrefix) aTo += aPrefix; aTo += nsPrintfCString("%s%s (0x%p)", mManager->Name(), Name(), this); - ::PrintInfo(aTo, AsShadowLayer()); + ::PrintInfo(aTo, AsLayerComposite()); if (mUseClipRect) { AppendToString(aTo, mClipRect, " [clip=", "]"); @@ -1312,19 +1312,19 @@ LayerManager::IsLogEnabled() } static nsACString& -PrintInfo(nsACString& aTo, ShadowLayer* aShadowLayer) +PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite) { - if (!aShadowLayer) { + if (!aLayerComposite) { return aTo; } - if (const nsIntRect* clipRect = aShadowLayer->GetShadowClipRect()) { + if (const nsIntRect* clipRect = aLayerComposite->GetShadowClipRect()) { AppendToString(aTo, *clipRect, " [shadow-clip=", "]"); } - if (!aShadowLayer->GetShadowTransform().IsIdentity()) { - AppendToString(aTo, aShadowLayer->GetShadowTransform(), " [shadow-transform=", "]"); + if (!aLayerComposite->GetShadowTransform().IsIdentity()) { + AppendToString(aTo, aLayerComposite->GetShadowTransform(), " [shadow-transform=", "]"); } - if (!aShadowLayer->GetShadowVisibleRegion().IsEmpty()) { - AppendToString(aTo, aShadowLayer->GetShadowVisibleRegion(), " [shadow-visible=", "]"); + if (!aLayerComposite->GetShadowVisibleRegion().IsEmpty()) { + AppendToString(aTo, aLayerComposite->GetShadowVisibleRegion(), " [shadow-visible=", "]"); } return aTo; } diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 0d3cd5178ff9..d8fd283f0fe2 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -60,10 +60,10 @@ class CanvasLayer; class ReadbackLayer; class ReadbackProcessor; class RefLayer; -class ShadowLayer; +class LayerComposite; class ShadowableLayer; class ShadowLayerForwarder; -class ShadowLayerManager; +class LayerManagerComposite; class SpecificLayerAttributes; class SurfaceDescriptor; class Compositor; @@ -168,7 +168,7 @@ public: virtual ShadowLayerForwarder* AsShadowForwarder() { return nullptr; } - virtual ShadowLayerManager* AsShadowManager() + virtual LayerManagerComposite* AsLayerManagerComposite() { return nullptr; } /** @@ -1015,10 +1015,10 @@ public: virtual ColorLayer* AsColorLayer() { return nullptr; } /** - * Dynamic cast to a ShadowLayer. Return null if this is not a - * ShadowLayer. Can be used anytime. + * Dynamic cast to a LayerComposite. Return null if this is not a + * LayerComposite. Can be used anytime. */ - virtual ShadowLayer* AsShadowLayer() { return nullptr; } + virtual LayerComposite* AsLayerComposite() { return nullptr; } /** * Dynamic cast to a ShadowableLayer. Return null if this is not a @@ -1026,12 +1026,6 @@ public: */ virtual ShadowableLayer* AsShadowableLayer() { return nullptr; } - /** - * Dynamic cast to a LayerComposite. Return null if this is not a - * ShadowableLayer. Can be used anytime. - */ - virtual LayerComposite* AsLayerComposite() { return nullptr; } - // These getters can be used anytime. They return the effective // values that should be used when drawing this layer to screen, // accounting for this layer possibly being a shadow. diff --git a/gfx/layers/RenderTrace.cpp b/gfx/layers/RenderTrace.cpp index 764716b2417e..83e1bdc172af 100644 --- a/gfx/layers/RenderTrace.cpp +++ b/gfx/layers/RenderTrace.cpp @@ -35,7 +35,7 @@ void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRoo trans.TransformBounds(rect); if (strcmp(aLayer->Name(), "ContainerLayer") != 0 && - strcmp(aLayer->Name(), "ShadowContainerLayer") != 0) { + strcmp(aLayer->Name(), "ContainerLayerComposite") != 0) { printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n", aLayer->Name(), (int)PR_IntervalNow(), colorId, aColor, diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 46e61eb1ae3a..375e935ee752 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -1251,7 +1251,7 @@ BasicShadowLayerManager::ForwardTransaction() RenderTraceScope rendertrace("Foward Transaction", "000090"); mPhase = PHASE_FORWARD; - // forward this transaction's changeset to our ShadowLayerManager + // forward this transaction's changeset to our LayerManagerComposite AutoInfallibleTArray replies; if (HasShadowManager() && ShadowLayerForwarder::EndTransaction(&replies)) { for (nsTArray::size_type i = 0; i < replies.Length(); ++i) { diff --git a/gfx/layers/basic/BasicLayers.h b/gfx/layers/basic/BasicLayers.h index 4811e8b76498..07cadeaf9110 100644 --- a/gfx/layers/basic/BasicLayers.h +++ b/gfx/layers/basic/BasicLayers.h @@ -21,11 +21,11 @@ namespace mozilla { namespace layers { class BasicShadowableLayer; -class ShadowThebesLayer; -class ShadowContainerLayer; -class ShadowImageLayer; -class ShadowCanvasLayer; -class ShadowColorLayer; +class ThebesLayerComposite; +class ContainerLayerComposite; +class ImageLayerComposite; +class CanvasLayerComposite; +class ColorLayerComposite; class ReadbackProcessor; class ImageFactory; class PaintLayerContext; diff --git a/gfx/layers/basic/BasicThebesLayer.cpp b/gfx/layers/basic/BasicThebesLayer.cpp index afbc52ff1d29..af56d0308ad1 100644 --- a/gfx/layers/basic/BasicThebesLayer.cpp +++ b/gfx/layers/basic/BasicThebesLayer.cpp @@ -349,7 +349,7 @@ protected: virtual already_AddRefed CreateBuffer(ContentType, const nsIntRect&, uint32_t, gfxASurface**) { - NS_RUNTIMEABORT("ShadowThebesLayer can't paint content"); + NS_RUNTIMEABORT("ThebesLayerComposite can't paint content"); return nullptr; } }; diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index a8f1c028d4b8..1bc616f7c37f 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -43,7 +43,7 @@ class CompositableChild; * * To do in-transaction texture transfer (the default), call * ShadowLayerForwarder::Attach(CompositableClient*, ShadowableLayer*). This - * will let the ShadowLayer on the compositor side know which CompositableHost + * will let the LayerComposite on the compositor side know which CompositableHost * to use for compositing. * * To do async texture transfer (like async-video), the CompositableClient diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 5c0b3556fe3f..643a6c6f4407 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -9,6 +9,7 @@ #include "nsIWidget.h" #include "gfxUtils.h" #include "gfxPlatform.h" +#include "mozilla/layers/LayerManagerComposite.h" namespace mozilla { @@ -22,7 +23,7 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder) if (aForwarder->GetCompositorBackendType() != LAYERS_OPENGL) { return nullptr; } - if (ShadowLayerManager::SupportsDirectTexturing() || + if (LayerManagerComposite::SupportsDirectTexturing() || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) { return new ContentClientDoubleBuffered(aForwarder); } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index bc0b37f9682b..cd45fe8032c9 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -21,11 +21,9 @@ class GLContext; namespace layers { -class PTextureChild; class ContentClient; class PlanarYCbCrImage; class Image; -class PTextureChild; class CompositableForwarder; /** diff --git a/gfx/layers/composite/CanvasLayerComposite.cpp b/gfx/layers/composite/CanvasLayerComposite.cpp index 8637dd2b309d..ff74aaa66d13 100644 --- a/gfx/layers/composite/CanvasLayerComposite.cpp +++ b/gfx/layers/composite/CanvasLayerComposite.cpp @@ -17,7 +17,7 @@ using namespace mozilla; using namespace mozilla::layers; CanvasLayerComposite::CanvasLayerComposite(LayerManagerComposite* aManager) - : ShadowCanvasLayer(aManager, nullptr) + : CanvasLayer(aManager, nullptr) , LayerComposite(aManager) , mImageHost(nullptr) { diff --git a/gfx/layers/composite/CanvasLayerComposite.h b/gfx/layers/composite/CanvasLayerComposite.h index 6808f7de5ae5..47fdf9d37c30 100644 --- a/gfx/layers/composite/CanvasLayerComposite.h +++ b/gfx/layers/composite/CanvasLayerComposite.h @@ -7,7 +7,7 @@ #define GFX_CanvasLayerComposite_H -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "gfxASurface.h" #if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO) #include "mozilla/X11Util.h" @@ -20,14 +20,12 @@ namespace layers { // canvas is identical to compositing an image. class ImageHost; -// NB: eventually we'll have separate shadow canvas2d and shadow -// canvas3d layers, but currently they look the same from the -// perspective of the compositor process -class CanvasLayerComposite : public ShadowCanvasLayer, +class CanvasLayerComposite : public CanvasLayer, public LayerComposite { public: CanvasLayerComposite(LayerManagerComposite* aManager); + virtual ~CanvasLayerComposite(); // CanvasLayer impl @@ -38,14 +36,6 @@ public: virtual LayerRenderState GetRenderState() MOZ_OVERRIDE; - // ShadowCanvasLayer impl - virtual void Swap(const SurfaceDescriptor& aNewFront, - bool needYFlip, - SurfaceDescriptor* aNewBack) MOZ_OVERRIDE - { - NS_ERROR("Should never be called"); - } - virtual void SetCompositableHost(CompositableHost* aHost) MOZ_OVERRIDE; virtual void Disconnect() MOZ_OVERRIDE @@ -53,7 +43,6 @@ public: Destroy(); } - // LayerComposite impl virtual Layer* GetLayer() MOZ_OVERRIDE; virtual void RenderLayer(const nsIntPoint& aOffset, const nsIntRect& aClipRect) MOZ_OVERRIDE; @@ -64,6 +53,8 @@ public: virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; } + void SetBounds(nsIntRect aBounds) { mBounds = aBounds; } + #ifdef MOZ_LAYERS_HAVE_LOG virtual const char* Name() const MOZ_OVERRIDE { return "CanvasLayerComposite"; } diff --git a/gfx/layers/composite/ColorLayerComposite.h b/gfx/layers/composite/ColorLayerComposite.h index 076ca1fdc0a5..468c50b8fd00 100644 --- a/gfx/layers/composite/ColorLayerComposite.h +++ b/gfx/layers/composite/ColorLayerComposite.h @@ -9,18 +9,18 @@ #include "mozilla/layers/PLayerTransaction.h" #include "mozilla/layers/ShadowLayers.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" namespace mozilla { namespace layers { -class ColorLayerComposite : public ShadowColorLayer, +class ColorLayerComposite : public ColorLayer, public LayerComposite { public: ColorLayerComposite(LayerManagerComposite *aManager) - : ShadowColorLayer(aManager, nullptr) + : ColorLayer(aManager, nullptr) , LayerComposite(aManager) { MOZ_COUNT_CTOR(ColorLayerComposite); diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 48408f1ce3d1..c1a044b0bc11 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -152,7 +152,7 @@ ContainerRender(ContainerT* aContainer, } ContainerLayerComposite::ContainerLayerComposite(LayerManagerComposite *aManager) - : ShadowContainerLayer(aManager, nullptr) + : ContainerLayer(aManager, nullptr) , LayerComposite(aManager) { MOZ_COUNT_CTOR(ContainerLayerComposite); @@ -329,7 +329,7 @@ ContainerLayerComposite::CleanupResources() } RefLayerComposite::RefLayerComposite(LayerManagerComposite* aManager) - : ShadowRefLayer(aManager, nullptr) + : RefLayer(aManager, nullptr) , LayerComposite(aManager) { mImplData = static_cast(this); diff --git a/gfx/layers/composite/ContainerLayerComposite.h b/gfx/layers/composite/ContainerLayerComposite.h index c63a78a5cea7..da7d6462182c 100644 --- a/gfx/layers/composite/ContainerLayerComposite.h +++ b/gfx/layers/composite/ContainerLayerComposite.h @@ -10,7 +10,7 @@ #include "mozilla/layers/ShadowLayers.h" #include "Layers.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/Effects.h" #include "gfxUtils.h" @@ -19,7 +19,7 @@ namespace mozilla { namespace layers { -class ContainerLayerComposite : public ShadowContainerLayer, +class ContainerLayerComposite : public ContainerLayer, public LayerComposite { template @@ -29,6 +29,7 @@ class ContainerLayerComposite : public ShadowContainerLayer, const nsIntRect& aClipRect); public: ContainerLayerComposite(LayerManagerComposite *aManager); + ~ContainerLayerComposite(); void InsertAfter(Layer* aChild, Layer* aAfter); @@ -64,7 +65,7 @@ public: #endif }; -class RefLayerComposite : public ShadowRefLayer, +class RefLayerComposite : public RefLayer, public LayerComposite { template @@ -93,6 +94,8 @@ public: virtual void CleanupResources() MOZ_OVERRIDE; + virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; } + // ref layers don't use a compositable CompositableHost* GetCompositableHost() MOZ_OVERRIDE { return nullptr; } diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index 0d22ed5a4e96..e2c2b275f754 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -7,7 +7,7 @@ #define MOZILLA_GFX_IMAGEHOST_H #include "CompositableHost.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" namespace mozilla { namespace layers { diff --git a/gfx/layers/composite/ImageLayerComposite.cpp b/gfx/layers/composite/ImageLayerComposite.cpp index 0d1f657d2321..e28699652d33 100644 --- a/gfx/layers/composite/ImageLayerComposite.cpp +++ b/gfx/layers/composite/ImageLayerComposite.cpp @@ -22,7 +22,7 @@ namespace mozilla { namespace layers { ImageLayerComposite::ImageLayerComposite(LayerManagerComposite* aManager) - : ShadowImageLayer(aManager, nullptr) + : ImageLayer(aManager, nullptr) , LayerComposite(aManager) , mImageHost(nullptr) { diff --git a/gfx/layers/composite/ImageLayerComposite.h b/gfx/layers/composite/ImageLayerComposite.h index 9e470a6794f6..e95d648004b5 100644 --- a/gfx/layers/composite/ImageLayerComposite.h +++ b/gfx/layers/composite/ImageLayerComposite.h @@ -9,7 +9,7 @@ #include "mozilla/layers/PLayerTransaction.h" #include "mozilla/layers/ShadowLayers.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "ImageLayers.h" #include "mozilla/Mutex.h" @@ -18,24 +18,18 @@ namespace layers { class ImageHost; -class ImageLayerComposite : public ShadowImageLayer, +class ImageLayerComposite : public ImageLayer, public LayerComposite { typedef gl::TextureImage TextureImage; public: ImageLayerComposite(LayerManagerComposite* aManager); + virtual ~ImageLayerComposite(); virtual LayerRenderState GetRenderState() MOZ_OVERRIDE; - // ShadowImageLayer impl - virtual void Swap(const SurfaceDescriptor& aFront, - SurfaceDescriptor* aNewBack) - { - NS_ERROR("Not implemented"); - } - virtual void Disconnect() MOZ_OVERRIDE; virtual void SetCompositableHost(CompositableHost* aHost) MOZ_OVERRIDE; diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index ed8b8ded7291..74d80061748b 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -9,7 +9,7 @@ // typedefs conflicts. #include "mozilla/Util.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "ThebesLayerComposite.h" #include "ContainerLayerComposite.h" #include "ImageLayerComposite.h" @@ -21,6 +21,7 @@ #include "mozilla/Preferences.h" #include "mozilla/layers/ImageHost.h" #include "mozilla/layers/ContentHost.h" +#include "mozilla/layers/Compositor.h" #include "gfxContext.h" #include "gfxUtils.h" @@ -47,6 +48,7 @@ namespace mozilla { namespace layers { using namespace mozilla::gfx; +using namespace mozilla::gl; static LayerComposite* ToLayerComposite(Layer* aLayer) @@ -78,16 +80,20 @@ LayerManagerComposite::ClearCachedResources(Layer* aSubtree) // Do we need that? } - - /** * LayerManagerComposite */ LayerManagerComposite::LayerManagerComposite(Compositor* aCompositor) +: mCompositor(aCompositor) { - mCompositor = aCompositor; } +LayerManagerComposite::~LayerManagerComposite() +{ + Destroy(); +} + + bool LayerManagerComposite::Initialize() { @@ -543,38 +549,38 @@ LayerManagerComposite::ComputeRenderIntegrity() return 1.f; } -already_AddRefed -LayerManagerComposite::CreateShadowThebesLayer() +already_AddRefed +LayerManagerComposite::CreateThebesLayerComposite() { - if (LayerManagerComposite::mDestroyed) { + if (mDestroyed) { NS_WARNING("Call on destroyed layer manager"); return nullptr; } return nsRefPtr(new ThebesLayerComposite(this)).forget(); } -already_AddRefed -LayerManagerComposite::CreateShadowContainerLayer() +already_AddRefed +LayerManagerComposite::CreateContainerLayerComposite() { - if (LayerManagerComposite::mDestroyed) { + if (mDestroyed) { NS_WARNING("Call on destroyed layer manager"); return nullptr; } return nsRefPtr(new ContainerLayerComposite(this)).forget(); } -already_AddRefed -LayerManagerComposite::CreateShadowImageLayer() +already_AddRefed +LayerManagerComposite::CreateImageLayerComposite() { - if (LayerManagerComposite::mDestroyed) { + if (mDestroyed) { NS_WARNING("Call on destroyed layer manager"); return nullptr; } return nsRefPtr(new ImageLayerComposite(this)).forget(); } -already_AddRefed -LayerManagerComposite::CreateShadowColorLayer() +already_AddRefed +LayerManagerComposite::CreateColorLayerComposite() { if (LayerManagerComposite::mDestroyed) { NS_WARNING("Call on destroyed layer manager"); @@ -583,8 +589,8 @@ LayerManagerComposite::CreateShadowColorLayer() return nsRefPtr(new ColorLayerComposite(this)).forget(); } -already_AddRefed -LayerManagerComposite::CreateShadowCanvasLayer() +already_AddRefed +LayerManagerComposite::CreateCanvasLayerComposite() { if (LayerManagerComposite::mDestroyed) { NS_WARNING("Call on destroyed layer manager"); @@ -593,8 +599,8 @@ LayerManagerComposite::CreateShadowCanvasLayer() return nsRefPtr(new CanvasLayerComposite(this)).forget(); } -already_AddRefed -LayerManagerComposite::CreateShadowRefLayer() +already_AddRefed +LayerManagerComposite::CreateRefLayerComposite() { if (LayerManagerComposite::mDestroyed) { NS_WARNING("Call on destroyed layer manager"); @@ -640,6 +646,18 @@ LayerManagerComposite::CreateDrawTarget(const IntSize &aSize, return LayerManager::CreateDrawTarget(aSize, aFormat); } +LayerComposite::LayerComposite(LayerManagerComposite *aManager) + : mCompositeManager(aManager) + , mCompositor(aManager->GetCompositor()) + , mShadowOpacity(1.0) + , mUseShadowClipRect(false) + , mDestroyed(false) +{ } + +LayerComposite::~LayerComposite() +{ +} + void LayerComposite::Destroy() { @@ -649,5 +667,65 @@ LayerComposite::Destroy() } } +const nsIntSize& +LayerManagerComposite::GetWidgetSize() +{ + return mCompositor->GetWidgetSize(); +} + +void +LayerManagerComposite::SetCompositorID(uint32_t aID) +{ + NS_ASSERTION(mCompositor, "No compositor"); + mCompositor->SetCompositorID(aID); +} + +void +LayerManagerComposite::NotifyShadowTreeTransaction() +{ + mCompositor->NotifyLayersTransaction(); +} + +bool +LayerManagerComposite::CanUseCanvasLayerForSize(const gfxIntSize &aSize) +{ + return mCompositor->CanUseCanvasLayerForSize(aSize); +} + +TextureFactoryIdentifier +LayerManagerComposite::GetTextureFactoryIdentifier() +{ + return mCompositor->GetTextureFactoryIdentifier(); +} + +int32_t +LayerManagerComposite::GetMaxTextureSize() const +{ + return mCompositor->GetMaxTextureSize(); +} + +#ifndef MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS + +/*static*/ already_AddRefed +LayerManagerComposite::OpenDescriptorForDirectTexturing(GLContext*, + const SurfaceDescriptor&, + GLenum) +{ + return nullptr; +} + +/*static*/ bool +LayerManagerComposite::SupportsDirectTexturing() +{ + return false; +} + +/*static*/ void +LayerManagerComposite::PlatformSyncBeforeReplyUpdate() +{ +} + +#endif // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS) + } /* layers */ } /* mozilla */ diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index d5df8e46eac7..4787d9fb6d89 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -10,6 +10,7 @@ #include "mozilla/layers/ShadowLayers.h" #include "Composer2D.h" #include "mozilla/TimeStamp.h" +#include "Layers.h" #ifdef XP_WIN #include @@ -30,43 +31,23 @@ namespace mozilla { namespace layers { class LayerComposite; -class ShadowThebesLayer; -class ShadowContainerLayer; -class ShadowImageLayer; -class ShadowCanvasLayer; -class ShadowColorLayer; +class ThebesLayerComposite; +class ContainerLayerComposite; +class ImageLayerComposite; +class CanvasLayerComposite; +class ColorLayerComposite; +class RefLayerComposite; class CompositableHost; +class EffectChain; +class TiledLayerComposer; -/** - * Composite layers are for use with OMTC on the compositor thread only. There - * must be corresponding Basic layers on the content thread. For composite - * layers, the layer manager only maintains the layer tree, all rendering is - * done by a Compositor (see Compositor.h). As such, composite layers are - * platform-independent and can be used on any platform for which there is a - * Compositor implementation. - * - * The composite layer tree reflects exactly the basic layer tree. To - * composite to screen, the layer manager walks the layer tree calling render - * methods which in turn call into their CompositableHosts' Composite methods. - * These call Compositor::DrawQuad to do the rendering. - * - * Mostly, layers are updated during the layers transaction. This is done from - * CompositableClient to CompositableHost without interacting with the layer. - * - * mCompositor is stored in ShadowLayerManager. - * - * Post-landing TODO: merge LayerComposite with ShadowLayer - */ -class THEBES_API LayerManagerComposite : public ShadowLayerManager +class THEBES_API LayerManagerComposite : public LayerManager { public: LayerManagerComposite(Compositor* aCompositor); - virtual ~LayerManagerComposite() - { - Destroy(); - } - - virtual void Destroy(); + ~LayerManagerComposite(); + + virtual void Destroy() MOZ_OVERRIDE; /** * return True if initialization was succesful, false when it was not. @@ -90,7 +71,7 @@ public: /** * LayerManager implementation. */ - virtual ShadowLayerManager* AsShadowManager() MOZ_OVERRIDE + virtual LayerManagerComposite* AsLayerManagerComposite() MOZ_OVERRIDE { return this; } @@ -100,10 +81,7 @@ public: void BeginTransaction() MOZ_OVERRIDE; void BeginTransactionWithTarget(gfxContext* aTarget) MOZ_OVERRIDE; - virtual void NotifyShadowTreeTransaction() MOZ_OVERRIDE - { - mCompositor->NotifyLayersTransaction(); - } + void NotifyShadowTreeTransaction(); virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE; virtual void EndTransaction(DrawThebesLayerCallback aCallback, @@ -112,20 +90,11 @@ public: virtual void SetRoot(Layer* aLayer) MOZ_OVERRIDE { mRoot = aLayer; } - virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE - { - return mCompositor->CanUseCanvasLayerForSize(aSize); - } + virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE; - virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE - { - return mCompositor->GetTextureFactoryIdentifier(); - } + virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE; - virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE - { - return mCompositor->GetMaxTextureSize(); - } + virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE; virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE; @@ -134,12 +103,12 @@ public: virtual already_AddRefed CreateImageLayer() MOZ_OVERRIDE; virtual already_AddRefed CreateColorLayer() MOZ_OVERRIDE; virtual already_AddRefed CreateCanvasLayer() MOZ_OVERRIDE; - virtual already_AddRefed CreateShadowThebesLayer() MOZ_OVERRIDE; - virtual already_AddRefed CreateShadowContainerLayer() MOZ_OVERRIDE; - virtual already_AddRefed CreateShadowImageLayer() MOZ_OVERRIDE; - virtual already_AddRefed CreateShadowColorLayer() MOZ_OVERRIDE; - virtual already_AddRefed CreateShadowCanvasLayer() MOZ_OVERRIDE; - virtual already_AddRefed CreateShadowRefLayer() MOZ_OVERRIDE; + already_AddRefed CreateThebesLayerComposite(); + already_AddRefed CreateContainerLayerComposite(); + already_AddRefed CreateImageLayerComposite(); + already_AddRefed CreateColorLayerComposite(); + already_AddRefed CreateCanvasLayerComposite(); + already_AddRefed CreateRefLayerComposite(); virtual LayersBackend GetBackendType() MOZ_OVERRIDE { @@ -204,10 +173,7 @@ public: CreateDrawTarget(const mozilla::gfx::IntSize &aSize, mozilla::gfx::SurfaceFormat aFormat) MOZ_OVERRIDE; - const nsIntSize& GetWidgetSize() - { - return mCompositor->GetWidgetSize(); - } + const nsIntSize& GetWidgetSize(); /** * Calculates the 'completeness' of the rendering that intersected with the @@ -218,6 +184,34 @@ public: */ float ComputeRenderIntegrity(); + /** + * Try to open |aDescriptor| for direct texturing. If the + * underlying surface supports direct texturing, a non-null + * TextureImage is returned. Otherwise null is returned. + */ + static already_AddRefed + OpenDescriptorForDirectTexturing(gl::GLContext* aContext, + const SurfaceDescriptor& aDescriptor, + GLenum aWrapMode); + + /** + * returns true if PlatformAllocBuffer will return a buffer that supports + * direct texturing + */ + static bool SupportsDirectTexturing(); + + static void PlatformSyncBeforeReplyUpdate(); + + void SetCompositorID(uint32_t aID); + + Compositor* GetCompositor() const + { + return mCompositor; + } + + bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface); + RefPtr mCompositor; + private: /** Region we're clipping our current drawing to. */ nsIntRegion mClippingRegion; @@ -255,24 +249,32 @@ private: bool mInTransaction; }; - - - /** - * General information and tree management for layers. + * Composite layers are for use with OMTC on the compositor thread only. There + * must be corresponding Basic layers on the content thread. For composite + * layers, the layer manager only maintains the layer tree, all rendering is + * done by a Compositor (see Compositor.h). As such, composite layers are + * platform-independent and can be used on any platform for which there is a + * Compositor implementation. + * + * The composite layer tree reflects exactly the basic layer tree. To + * composite to screen, the layer manager walks the layer tree calling render + * methods which in turn call into their CompositableHosts' Composite methods. + * These call Compositor::DrawQuad to do the rendering. + * + * Mostly, layers are updated during the layers transaction. This is done from + * CompositableClient to CompositableHost without interacting with the layer. + * + * A reference to the Compositor is stored in LayerManagerComposite. */ class LayerComposite { public: - LayerComposite(LayerManagerComposite *aManager) - : mCompositeManager(aManager) - , mCompositor(aManager->GetCompositor()) - , mDestroyed(false) - { } + LayerComposite(LayerManagerComposite* aManager); - virtual ~LayerComposite() {} + virtual ~LayerComposite(); - virtual LayerComposite *GetFirstChildComposite() + virtual LayerComposite* GetFirstChildComposite() { return nullptr; } @@ -297,9 +299,53 @@ public: virtual TiledLayerComposer* GetTiledLayerComposer() { return nullptr; } + + virtual void DestroyFrontBuffer() { } + + /** + * The following methods are + * + * CONSTRUCTION PHASE ONLY + * + * They are analogous to the Layer interface. + */ + void SetShadowVisibleRegion(const nsIntRegion& aRegion) + { + mShadowVisibleRegion = aRegion; + } + + void SetShadowOpacity(float aOpacity) + { + mShadowOpacity = aOpacity; + } + + void SetShadowClipRect(const nsIntRect* aRect) + { + mUseShadowClipRect = aRect != nullptr; + if (aRect) { + mShadowClipRect = *aRect; + } + } + + void SetShadowTransform(const gfx3DMatrix& aMatrix) + { + mShadowTransform = aMatrix; + } + + // These getters can be used anytime. + float GetShadowOpacity() { return mShadowOpacity; } + const nsIntRect* GetShadowClipRect() { return mUseShadowClipRect ? &mShadowClipRect : nullptr; } + const nsIntRegion& GetShadowVisibleRegion() { return mShadowVisibleRegion; } + const gfx3DMatrix& GetShadowTransform() { return mShadowTransform; } + protected: + gfx3DMatrix mShadowTransform; + nsIntRegion mShadowVisibleRegion; + nsIntRect mShadowClipRect; LayerManagerComposite* mCompositeManager; RefPtr mCompositor; + float mShadowOpacity; + bool mUseShadowClipRect; bool mDestroyed; }; diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/ThebesLayerComposite.cpp index e6a79b9866ca..57a2f0081b54 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/ThebesLayerComposite.cpp @@ -26,7 +26,7 @@ namespace mozilla { namespace layers { ThebesLayerComposite::ThebesLayerComposite(LayerManagerComposite *aManager) - : ShadowThebesLayer(aManager, nullptr) + : ThebesLayer(aManager, nullptr) , LayerComposite(aManager) , mBuffer(nullptr) { diff --git a/gfx/layers/composite/ThebesLayerComposite.h b/gfx/layers/composite/ThebesLayerComposite.h index 8bc615e46e41..531b3492f9b6 100644 --- a/gfx/layers/composite/ThebesLayerComposite.h +++ b/gfx/layers/composite/ThebesLayerComposite.h @@ -10,7 +10,7 @@ #include "mozilla/layers/ShadowLayers.h" #include "Layers.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "base/task.h" @@ -25,7 +25,7 @@ namespace layers { class ContentHost; -class ThebesLayerComposite : public ShadowThebesLayer, +class ThebesLayerComposite : public ThebesLayer, public LayerComposite { public: @@ -34,11 +34,6 @@ public: virtual void Disconnect() MOZ_OVERRIDE; - virtual void SetValidRegion(const nsIntRegion& aRegion) MOZ_OVERRIDE - { - ShadowThebesLayer::SetValidRegion(aRegion); - } - virtual LayerRenderState GetRenderState() MOZ_OVERRIDE; CompositableHost* GetCompositableHost() MOZ_OVERRIDE; @@ -60,10 +55,23 @@ public: void EnsureTiled() { mRequiresTiledProperties = true; } -#ifdef MOZ_LAYERS_HAVE_LOG - virtual const char* Name() const MOZ_OVERRIDE { return "ThebesLayerComposite"; } + virtual void InvalidateRegion(const nsIntRegion& aRegion) + { + NS_RUNTIMEABORT("ThebesLayerComposites can't fill invalidated regions"); + } + + void SetValidRegion(const nsIntRegion& aRegion) + { + MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ValidRegion", this)); + mValidRegion = aRegion; + Mutated(); + } + + MOZ_LAYER_DECL_NAME("ThebesLayerComposite", TYPE_SHADOW) protected: + +#ifdef MOZ_LAYERS_HAVE_LOG virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix) MOZ_OVERRIDE; #endif diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index 235be3f91db1..57999da786f1 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -13,7 +13,8 @@ #include "mozilla/layers/ContentHost.h" #include "ShadowLayerParent.h" #include "TiledLayerBuffer.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" +#include "mozilla/layers/ThebesLayerComposite.h" #include "CompositorParent.h" namespace mozilla { @@ -56,7 +57,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation compositableParent->GetCompositableHost(); Layer* layer = compositable ? compositable->GetLayer() : nullptr; - ShadowLayer* shadowLayer = layer ? layer->AsShadowLayer() : nullptr; + LayerComposite* shadowLayer = layer ? layer->AsLayerComposite() : nullptr; if (shadowLayer) { Compositor* compositor = static_cast(layer->Manager())->GetCompositor(); compositable->SetCompositor(compositor); @@ -109,8 +110,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation CompositableParent* compositableParent = static_cast(op.compositableParent()); CompositableHost* compositable = compositableParent->GetCompositableHost(); - ShadowThebesLayer* thebes = - static_cast(compositable->GetLayer()); + ThebesLayerComposite* thebes = + static_cast(compositable->GetLayer()); const ThebesBufferData& bufferData = op.bufferData(); diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index a2a8f2116775..c8999265261d 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -403,9 +403,9 @@ void CompositorParent::NotifyShadowTreeTransaction() { if (mLayerManager) { - ShadowLayerManager *shadow = mLayerManager->AsShadowManager(); - if (shadow) { - shadow->NotifyShadowTreeTransaction(); + LayerManagerComposite* managerComposite = mLayerManager->AsLayerManagerComposite(); + if (managerComposite) { + managerComposite->NotifyShadowTreeTransaction(); } } ScheduleComposition(); @@ -662,14 +662,14 @@ CompositorParent::TransformFixedLayers(Layer* aLayer, layerTransform.ScalePost(1.0f/aLayer->GetPostXScale(), 1.0f/aLayer->GetPostYScale(), 1); - ShadowLayer* shadow = aLayer->AsShadowLayer(); - shadow->SetShadowTransform(layerTransform); + LayerComposite* layerComposite = aLayer->AsLayerComposite(); + layerComposite->SetShadowTransform(layerTransform); const nsIntRect* clipRect = aLayer->GetClipRect(); if (clipRect) { nsIntRect transformedClipRect(*clipRect); transformedClipRect.MoveBy(translation.x, translation.y); - shadow->SetShadowClipRect(&transformedClipRect); + layerComposite->SetShadowClipRect(&transformedClipRect); } // The transform has now been applied, so there's no need to iterate over @@ -683,18 +683,18 @@ CompositorParent::TransformFixedLayers(Layer* aLayer, } } -// Go down shadow layer tree, setting properties to match their non-shadow -// counterparts. +// Go down the composite layer tree, setting properties to match their +// content-side counterparts. static void SetShadowProperties(Layer* aLayer) { // FIXME: Bug 717688 -- Do these updates in LayerTransactionParent::RecvUpdate. - ShadowLayer* shadow = aLayer->AsShadowLayer(); - // Set the shadow's base transform to the layer's base transform. - shadow->SetShadowTransform(aLayer->GetBaseTransform()); - shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion()); - shadow->SetShadowClipRect(aLayer->GetClipRect()); - shadow->SetShadowOpacity(aLayer->GetOpacity()); + LayerComposite* layerComposite = aLayer->AsLayerComposite(); + // Set the layerComposite's base transform to the layer's base transform. + layerComposite->SetShadowTransform(aLayer->GetBaseTransform()); + layerComposite->SetShadowVisibleRegion(aLayer->GetVisibleRegion()); + layerComposite->SetShadowClipRect(aLayer->GetClipRect()); + layerComposite->SetShadowOpacity(aLayer->GetOpacity()); for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) { @@ -793,11 +793,11 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint) Animatable interpolatedValue; SampleValue(portion, animation, animData.mStartValues[segmentIndex], animData.mEndValues[segmentIndex], &interpolatedValue); - ShadowLayer* shadow = aLayer->AsShadowLayer(); + LayerComposite* layerComposite = aLayer->AsLayerComposite(); switch (animation.property()) { case eCSSProperty_opacity: { - shadow->SetShadowOpacity(interpolatedValue.get_float()); + layerComposite->SetShadowOpacity(interpolatedValue.get_float()); break; } case eCSSProperty_transform: @@ -809,7 +809,7 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint) 1); } NS_ASSERTION(!aLayer->GetIsFixedPosition(), "Can't animate transforms on fixed-position layers"); - shadow->SetShadowTransform(matrix); + layerComposite->SetShadowTransform(matrix); break; } default: @@ -843,7 +843,7 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame, } if (AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController()) { - ShadowLayer* shadow = aLayer->AsShadowLayer(); + LayerComposite* layerComposite = aLayer->AsLayerComposite(); ViewTransform treeTransform; *aWantNextFrame |= @@ -861,7 +861,7 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame, transform.ScalePost(1.0f/aLayer->GetPostXScale(), 1.0f/aLayer->GetPostYScale(), 1); - shadow->SetShadowTransform(transform); + layerComposite->SetShadowTransform(transform); gfx::Margin fixedLayerMargins(0, 0, 0, 0); TransformFixedLayers( @@ -879,7 +879,7 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame, void CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRootTransform) { - ShadowLayer* shadow = aLayer->AsShadowLayer(); + LayerComposite* layerComposite = aLayer->AsLayerComposite(); ContainerLayer* container = aLayer->AsContainerLayer(); const FrameMetrics& metrics = container->GetFrameMetrics(); @@ -991,7 +991,7 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo computedTransform.ScalePost(1.0f/container->GetPostXScale(), 1.0f/container->GetPostYScale(), 1); - shadow->SetShadowTransform(computedTransform); + layerComposite->SetShadowTransform(computedTransform); TransformFixedLayers(aLayer, offset, scaleDiff, fixedLayerMargins); } @@ -1063,9 +1063,9 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree, SetShadowProperties(root); } ScheduleComposition(); - ShadowLayerManager *shadow = mLayerManager->AsShadowManager(); - if (shadow) { - shadow->NotifyShadowTreeTransaction(); + LayerManagerComposite *layerComposite = mLayerManager->AsLayerManagerComposite(); + if (layerComposite) { + layerComposite->NotifyShadowTreeTransaction(); } } @@ -1132,7 +1132,7 @@ CompositorParent::AllocPLayerTransaction(const LayersBackend& aBackendHint, nsRefPtr layerManager = new BasicShadowLayerManager(mWidget); mWidget = NULL; mLayerManager = layerManager; - ShadowLayerManager* slm = layerManager->AsShadowManager(); + LayerManagerComposite* slm = layerManager->AsLayerManagerComposite(); if (!slm) { return NULL; } @@ -1375,7 +1375,7 @@ CrossProcessCompositorParent::AllocPLayerTransaction(const LayersBackend& aBacke nsRefPtr lm = sCurrentCompositor->GetLayerManager(); *aTextureFactoryIdentifier = lm->GetTextureFactoryIdentifier(); - return new LayerTransactionParent(lm->AsShadowManager(), this, aId); + return new LayerTransactionParent(lm->AsLayerManagerComposite(), this, aId); } bool diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 6c42187cdc51..45ceff1e24a8 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -21,7 +21,7 @@ #include "mozilla/Monitor.h" #include "mozilla/TimeStamp.h" #include "ShadowLayersManager.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" class nsIWidget; namespace base { diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index 38f8b6031ba5..cf1f84fac60e 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -16,6 +16,7 @@ #include "mozilla/layers/TextureClient.h" #include "mozilla/layers/ImageClient.h" #include "mozilla/layers/LayersTypes.h" +#include "ShadowLayers.h" using namespace base; using namespace mozilla::ipc; diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 7d52aaa198cb..68ace09102e7 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -59,7 +59,7 @@ ImageBridgeParent::RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply) // Ensure that any pending operations involving back and front // buffers have completed, so that neither process stomps on the // other's buffer contents. - ShadowLayerManager::PlatformSyncBeforeReplyUpdate(); + LayerManagerComposite::PlatformSyncBeforeReplyUpdate(); return true; } diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 058df70e3cbd..7444a7d076c9 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -21,6 +21,11 @@ #include "TiledLayerBuffer.h" #include "gfxPlatform.h" #include "CompositableHost.h" +#include "mozilla/layers/ThebesLayerComposite.h" +#include "mozilla/layers/ImageLayerComposite.h" +#include "mozilla/layers/ColorLayerComposite.h" +#include "mozilla/layers/ContainerLayerComposite.h" +#include "mozilla/layers/CanvasLayerComposite.h" typedef std::vector EditReplyVector; @@ -47,13 +52,13 @@ cast(const PCompositableParent* in) template static ShadowLayerParent* -AsShadowLayer(const OpCreateT& op) +AsLayerComposite(const OpCreateT& op) { return cast(op.layerParent()); } static ShadowLayerParent* -AsShadowLayer(const OpSetRoot& op) +AsLayerComposite(const OpSetRoot& op) { return cast(op.rootParent()); } @@ -125,7 +130,7 @@ ShadowChild(const OpRaiseToTopChild& op) //-------------------------------------------------- // LayerTransactionParent -LayerTransactionParent::LayerTransactionParent(ShadowLayerManager* aManager, +LayerTransactionParent::LayerTransactionParent(LayerManagerComposite* aManager, ShadowLayersManager* aLayersManager, uint64_t aId) : mLayerManager(aManager) @@ -189,47 +194,47 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, case Edit::TOpCreateThebesLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateThebesLayer")); - nsRefPtr layer = - layer_manager()->CreateShadowThebesLayer(); - AsShadowLayer(edit.get_OpCreateThebesLayer())->Bind(layer); + nsRefPtr layer = + layer_manager()->CreateThebesLayerComposite(); + AsLayerComposite(edit.get_OpCreateThebesLayer())->Bind(layer); break; } case Edit::TOpCreateContainerLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateContainerLayer")); - nsRefPtr layer = layer_manager()->CreateShadowContainerLayer(); - AsShadowLayer(edit.get_OpCreateContainerLayer())->Bind(layer); + nsRefPtr layer = layer_manager()->CreateContainerLayerComposite(); + AsLayerComposite(edit.get_OpCreateContainerLayer())->Bind(layer); break; } case Edit::TOpCreateImageLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateImageLayer")); - nsRefPtr layer = - layer_manager()->CreateShadowImageLayer(); - AsShadowLayer(edit.get_OpCreateImageLayer())->Bind(layer); + nsRefPtr layer = + layer_manager()->CreateImageLayerComposite(); + AsLayerComposite(edit.get_OpCreateImageLayer())->Bind(layer); break; } case Edit::TOpCreateColorLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateColorLayer")); - nsRefPtr layer = layer_manager()->CreateShadowColorLayer(); - AsShadowLayer(edit.get_OpCreateColorLayer())->Bind(layer); + nsRefPtr layer = layer_manager()->CreateColorLayerComposite(); + AsLayerComposite(edit.get_OpCreateColorLayer())->Bind(layer); break; } case Edit::TOpCreateCanvasLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateCanvasLayer")); - nsRefPtr layer = - layer_manager()->CreateShadowCanvasLayer(); - AsShadowLayer(edit.get_OpCreateCanvasLayer())->Bind(layer); + nsRefPtr layer = + layer_manager()->CreateCanvasLayerComposite(); + AsLayerComposite(edit.get_OpCreateCanvasLayer())->Bind(layer); break; } case Edit::TOpCreateRefLayer: { MOZ_LAYERS_LOG(("[ParentSide] CreateRefLayer")); - nsRefPtr layer = - layer_manager()->CreateShadowRefLayer(); - AsShadowLayer(edit.get_OpCreateRefLayer())->Bind(layer); + nsRefPtr layer = + layer_manager()->CreateRefLayerComposite(); + AsLayerComposite(edit.get_OpCreateRefLayer())->Bind(layer); break; } @@ -238,7 +243,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes")); const OpSetLayerAttributes& osla = edit.get_OpSetLayerAttributes(); - Layer* layer = AsShadowLayer(osla)->AsLayer(); + Layer* layer = AsLayerComposite(osla)->AsLayer(); const LayerAttributes& attrs = osla.attrs(); const CommonLayerAttributes& common = attrs.common(); @@ -267,8 +272,8 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, case Specific::TThebesLayerAttributes: { MOZ_LAYERS_LOG(("[ParentSide] thebes layer")); - ShadowThebesLayer* thebesLayer = - static_cast(layer); + ThebesLayerComposite* thebesLayer = + static_cast(layer); const ThebesLayerAttributes& attrs = specific.get_ThebesLayerAttributes(); @@ -300,7 +305,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, static_cast(layer)->SetFilter( specific.get_CanvasLayerAttributes().filter()); - static_cast(layer)->SetBounds( + static_cast(layer)->SetBounds( specific.get_CanvasLayerAttributes().bounds()); break; @@ -328,7 +333,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, case Edit::TOpSetRoot: { MOZ_LAYERS_LOG(("[ParentSide] SetRoot")); - mRoot = AsShadowLayer(edit.get_OpSetRoot())->AsContainer(); + mRoot = AsLayerComposite(edit.get_OpSetRoot())->AsContainer(); break; } case Edit::TOpInsertAfter: { @@ -406,7 +411,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, // Ensure that any pending operations involving back and front // buffers have completed, so that neither process stomps on the // other's buffer contents. - ShadowLayerManager::PlatformSyncBeforeReplyUpdate(); + LayerManagerComposite::PlatformSyncBeforeReplyUpdate(); mShadowLayersManager->ShadowLayersUpdated(this, targetConfig, isFirstPaint); @@ -423,7 +428,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, void LayerTransactionParent::Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable) { - ShadowLayer* layer = aLayerParent->AsLayer()->AsShadowLayer(); + LayerComposite* layer = aLayerParent->AsLayer()->AsLayerComposite(); MOZ_ASSERT(layer); LayerComposite* layerComposite = aLayerParent->AsLayer()->AsLayerComposite(); diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h index c4ba71c37e4d..f63946214ed4 100644 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ b/gfx/layers/ipc/LayerTransactionParent.h @@ -22,7 +22,7 @@ class RenderFrameParent; namespace layers { class Layer; -class ShadowLayerManager; +class LayerManagerComposite; class ShadowLayerParent; class CompositableParent; @@ -34,14 +34,14 @@ class LayerTransactionParent : public PLayerTransactionParent, typedef InfallibleTArray EditReplyArray; public: - LayerTransactionParent(ShadowLayerManager* aManager, + LayerTransactionParent(LayerManagerComposite* aManager, ShadowLayersManager* aLayersManager, uint64_t aId); ~LayerTransactionParent(); void Destroy(); - ShadowLayerManager* layer_manager() const { return mLayerManager; } + LayerManagerComposite* layer_manager() const { return mLayerManager; } uint64_t GetId() const { return mId; } ContainerLayer* GetRoot() const { return mRoot; } @@ -88,11 +88,11 @@ protected: virtual PCompositableParent* AllocPCompositable(const TextureInfo& aInfo) MOZ_OVERRIDE; virtual bool DeallocPCompositable(PCompositableParent* actor) MOZ_OVERRIDE; - + void Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable); private: - nsRefPtr mLayerManager; + nsRefPtr mLayerManager; ShadowLayersManager* mShadowLayersManager; // Hold the root because it might be grafted under various // containers in the "real" layer tree diff --git a/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp b/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp index 749f536fa91f..ec9272cc2158 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp @@ -8,6 +8,7 @@ #include #include +#include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/PLayerTransaction.h" #include "ShadowLayers.h" @@ -78,21 +79,21 @@ ISurfaceAllocator::PlatformDestroySharedSurface(SurfaceDescriptor*) } /*static*/ already_AddRefed -ShadowLayerManager::OpenDescriptorForDirectTexturing(GLContext*, - const SurfaceDescriptor&, - GLenum) +LayerManagerComposite::OpenDescriptorForDirectTexturing(GLContext*, + const SurfaceDescriptor&, + GLenum) { return nullptr; } /*static*/ bool -ShadowLayerManager::SupportsDirectTexturing() +LayerManagerComposite::SupportsDirectTexturing() { return true; } /*static*/ void -ShadowLayerManager::PlatformSyncBeforeReplyUpdate() +LayerManagerComposite::PlatformSyncBeforeReplyUpdate() { } diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp index 7332dca17c76..7450ad728417 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp @@ -11,6 +11,8 @@ #include "mozilla/layers/PGrallocBufferParent.h" #include "mozilla/layers/PLayerTransactionChild.h" #include "mozilla/layers/ShadowLayers.h" +#include "mozilla/layers/LayerManagerComposite.h" +#include "mozilla/layers/CompositorTypes.h" #include "mozilla/unused.h" #include "nsXULAppAPI.h" @@ -220,11 +222,11 @@ GrallocBufferActor::Create(const gfxIntSize& aSize, } /*static*/ already_AddRefed -ShadowLayerManager::OpenDescriptorForDirectTexturing(GLContext* aGL, - const SurfaceDescriptor& aDescriptor, - GLenum aWrapMode) +LayerManagerComposite::OpenDescriptorForDirectTexturing(GLContext* aGL, + const SurfaceDescriptor& aDescriptor, + GLenum aWrapMode) { - PROFILER_LABEL("ShadowLayerManager", "OpenDescriptorForDirectTexturing"); + PROFILER_LABEL("LayerManagerComposite", "OpenDescriptorForDirectTexturing"); if (SurfaceDescriptor::TSurfaceDescriptorGralloc != aDescriptor.type()) { return nullptr; } @@ -233,13 +235,13 @@ ShadowLayerManager::OpenDescriptorForDirectTexturing(GLContext* aGL, } /*static*/ bool -ShadowLayerManager::SupportsDirectTexturing() +LayerManagerComposite::SupportsDirectTexturing() { return true; } /*static*/ void -ShadowLayerManager::PlatformSyncBeforeReplyUpdate() +LayerManagerComposite::PlatformSyncBeforeReplyUpdate() { // Nothing to be done for gralloc. } diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h b/gfx/layers/ipc/ShadowLayerUtilsGralloc.h index 64820a8e176a..0f25eb0560a0 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.h @@ -60,7 +60,7 @@ class GrallocBufferActor : public PGrallocBufferChild , public PGrallocBufferParent { friend class ShadowLayerForwarder; - friend class ShadowLayerManager; + friend class LayerManagerComposite; friend class ImageBridgeChild; typedef android::GraphicBuffer GraphicBuffer; diff --git a/gfx/layers/ipc/ShadowLayerUtilsMac.cpp b/gfx/layers/ipc/ShadowLayerUtilsMac.cpp index 9c80fefca6c2..3a965d29df2d 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsMac.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsMac.cpp @@ -7,6 +7,8 @@ #include "mozilla/layers/PLayerTransaction.h" #include "mozilla/layers/ShadowLayers.h" +#include "mozilla/layers/LayerManagerComposite.h" +#include "mozilla/layers/CompositorTypes.h" #include "gfxPlatform.h" @@ -72,7 +74,7 @@ ShadowLayerForwarder::PlatformSyncBeforeUpdate() } /*static*/ void -ShadowLayerManager::PlatformSyncBeforeReplyUpdate() +LayerManagerComposite::PlatformSyncBeforeReplyUpdate() { } @@ -83,15 +85,15 @@ ISurfaceAllocator::PlatformDestroySharedSurface(SurfaceDescriptor*) } /*static*/ already_AddRefed -ShadowLayerManager::OpenDescriptorForDirectTexturing(GLContext*, - const SurfaceDescriptor&, - GLenum) +LayerManagerComposite::OpenDescriptorForDirectTexturing(GLContext*, + const SurfaceDescriptor&, + GLenum) { return nullptr; } /*static*/ bool -ShadowLayerManager::SupportsDirectTexturing() +LayerManagerComposite::SupportsDirectTexturing() { return false; } diff --git a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp index b2a23f9027c1..a03c483cd4fa 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp @@ -6,8 +6,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/layers/PLayerTransaction.h" +#include "mozilla/layers/LayerManagerComposite.h" +#include "mozilla/layers/CompositorTypes.h" +#include "mozilla/layers/ISurfaceAllocator.h" #include "mozilla/layers/ShadowLayers.h" - + #include "gfxPlatform.h" #include "gfxXlibSurface.h" @@ -184,7 +187,7 @@ ShadowLayerForwarder::PlatformSyncBeforeUpdate() } /*static*/ void -ShadowLayerManager::PlatformSyncBeforeReplyUpdate() +LayerManagerComposite::PlatformSyncBeforeReplyUpdate() { if (UsingXCompositing()) { // If we're using X surfaces, we need to finish all pending @@ -197,16 +200,16 @@ ShadowLayerManager::PlatformSyncBeforeReplyUpdate() } /*static*/ already_AddRefed -ShadowLayerManager::OpenDescriptorForDirectTexturing(GLContext*, - const SurfaceDescriptor&, - GLenum) +LayerManagerComposite::OpenDescriptorForDirectTexturing(GLContext*, + const SurfaceDescriptor&, + GLenum) { // FIXME/bug XXXXXX: implement this using texture-from-pixmap return nullptr; } /*static*/ bool -ShadowLayerManager::SupportsDirectTexturing() +LayerManagerComposite::SupportsDirectTexturing() { return false; } diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index b07a01b99269..9c347fa5c8f0 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -591,25 +591,6 @@ ISurfaceAllocator::PlatformDestroySharedSurface(SurfaceDescriptor*) return false; } -/*static*/ already_AddRefed -ShadowLayerManager::OpenDescriptorForDirectTexturing(GLContext*, - const SurfaceDescriptor&, - GLenum) -{ - return nullptr; -} - -/*static*/ bool -ShadowLayerManager::SupportsDirectTexturing() -{ - return false; -} - -/*static*/ void -ShadowLayerManager::PlatformSyncBeforeReplyUpdate() -{ -} - #endif // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS) AutoOpenSurface::AutoOpenSurface(OpenMode aMode, diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index 15f270253302..e57544646bd6 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -18,6 +18,7 @@ #include "mozilla/layers/ISurfaceAllocator.h" #include "mozilla/dom/ScreenOrientation.h" #include "mozilla/layers/CompositableForwarder.h" +#include "mozilla/layers/CompositorTypes.h" class gfxSharedImageSurface; @@ -38,12 +39,12 @@ class PLayerChild; class PLayerTransactionChild; class PLayerTransactionParent; class ShadowableLayer; -class ShadowThebesLayer; -class ShadowContainerLayer; -class ShadowImageLayer; -class ShadowColorLayer; -class ShadowCanvasLayer; -class ShadowRefLayer; +class ThebesLayerComposite; +class ContainerLayerComposite; +class ImageLayerComposite; +class ColorLayerComposite; +class CanvasLayerComposite; +class RefLayerComposite; class SurfaceDescriptor; class ThebesBuffer; class TiledLayerComposer; @@ -57,12 +58,6 @@ class ImageClient; class CanvasClient; class ContentClient; -enum OpenMode { - OPEN_READ_ONLY, - OPEN_READ_WRITE -}; - - /** * We want to share layer trees across thread contexts and address @@ -91,13 +86,13 @@ enum OpenMode { * parent context. This comprises recording layer-tree modifications * into atomic transactions and pushing them over IPC. * - * ShadowLayerManager grafts layer subtrees published by child-context + * LayerManagerComposite grafts layer subtrees published by child-context * ShadowLayerForwarder(s) into a parent-context layer tree. * * (Advanced note: because our process tree may have a height >2, a * non-leaf subprocess may both receive updates from child processes * and publish them to parent processes. Put another way, - * LayerManagers may be both ShadowLayerManagers and + * LayerManagers may be both LayerManagerComposites and * ShadowLayerForwarders.) * * There are only shadow types for layers that have different shadow @@ -128,7 +123,7 @@ enum OpenMode { * compositable transactions. * A transaction is a set of changes to the layers and/or the compositables * that are sent and applied together to the compositor thread to keep the - * ShadowLayer in a coherent state. + * LayerComposite in a coherent state. * Layer transactions maintain the shape of the shadow layer tree, and * synchronize the texture data held by compositables. Layer transactions * are always between the content thread and the compositor thread. @@ -186,7 +181,7 @@ public: /** * Begin recording a transaction to be forwarded atomically to a - * ShadowLayerManager. + * LayerManagerComposite. */ void BeginTransaction(const nsIntRect& aTargetBounds, ScreenRotation aRotation, @@ -293,8 +288,8 @@ public: const nsIntRect& aRect); /** - * End the current transaction and forward it to ShadowLayerManager. - * |aReplies| are directions from the ShadowLayerManager to the + * End the current transaction and forward it to LayerManagerComposite. + * |aReplies| are directions from the LayerManagerComposite to the * caller of EndTransaction(). */ bool EndTransaction(InfallibleTArray* aReplies); @@ -308,7 +303,7 @@ public: } /** - * True if this is forwarding to a ShadowLayerManager. + * True if this is forwarding to a LayerManagerComposite. */ bool HasShadowManager() const { return !!mShadowManager; } PLayerTransactionChild* GetShadowManager() const { return mShadowManager; } @@ -317,23 +312,23 @@ public: * The following Alloc/Open/Destroy interfaces abstract over the * details of working with surfaces that are shared across * processes. They provide the glue between C++ Layers and the - * ShadowLayer IPC system. + * LayerComposite IPC system. * * The basic lifecycle is * * - a Layer needs a buffer. Its ShadowableLayer subclass calls * AllocBuffer(), then calls one of the Created*Buffer() methods * above to transfer the (temporary) front buffer to its - * ShadowLayer in the other process. The Layer needs a + * LayerComposite in the other process. The Layer needs a * gfxASurface to paint, so the ShadowableLayer uses * OpenDescriptor(backBuffer) to get that surface, and hands it * out to the Layer. * * - a Layer has painted new pixels. Its ShadowableLayer calls one * of the Painted*Buffer() methods above with the back buffer - * descriptor. This notification is forwarded to the ShadowLayer, + * descriptor. This notification is forwarded to the LayerComposite, * which uses OpenDescriptor() to access the newly-painted pixels. - * The ShadowLayer then updates its front buffer in a Layer- and + * The LayerComposite then updates its front buffer in a Layer- and * platform-dependent way, and sends a surface descriptor back to * the ShadowableLayer that becomes its new back back buffer. * @@ -342,7 +337,7 @@ public: * buffer descriptor. The actual back buffer surface is then * destroyed using DestroySharedSurface() just before notifying * the parent process. When the parent process is notified, the - * ShadowLayer also calls DestroySharedSurface() on its front + * LayerComposite also calls DestroySharedSurface() on its front * buffer, and the double-buffer pair is gone. */ @@ -357,7 +352,7 @@ public: /** * Construct a shadow of |aLayer| on the "other side", at the - * ShadowLayerManager. + * LayerManagerComposite. */ PLayerChild* ConstructShadowFor(ShadowableLayer* aLayer); @@ -432,66 +427,6 @@ private: bool mIsFirstPaint; }; -class ShadowLayerManager : public LayerManager -{ -public: - virtual ~ShadowLayerManager() {} - - virtual void GetBackendName(nsAString& name) { name.AssignLiteral("Shadow"); } - - /** CONSTRUCTION PHASE ONLY */ - virtual already_AddRefed CreateShadowThebesLayer() = 0; - /** CONSTRUCTION PHASE ONLY */ - virtual already_AddRefed CreateShadowContainerLayer() = 0; - /** CONSTRUCTION PHASE ONLY */ - virtual already_AddRefed CreateShadowImageLayer() = 0; - /** CONSTRUCTION PHASE ONLY */ - virtual already_AddRefed CreateShadowColorLayer() = 0; - /** CONSTRUCTION PHASE ONLY */ - virtual already_AddRefed CreateShadowCanvasLayer() = 0; - /** CONSTRUCTION PHASE ONLY */ - virtual already_AddRefed CreateShadowRefLayer() { return nullptr; } - - virtual void NotifyShadowTreeTransaction() {} - - /** - * Try to open |aDescriptor| for direct texturing. If the - * underlying surface supports direct texturing, a non-null - * TextureImage is returned. Otherwise null is returned. - */ - static already_AddRefed - OpenDescriptorForDirectTexturing(gl::GLContext* aContext, - const SurfaceDescriptor& aDescriptor, - GLenum aWrapMode); - - /** - * returns true if PlatformAllocBuffer will return a buffer that supports - * direct texturing - */ - static bool SupportsDirectTexturing(); - - static void PlatformSyncBeforeReplyUpdate(); - - void SetCompositorID(uint32_t aID) - { - NS_ASSERTION(mCompositor, "No compositor"); - mCompositor->SetCompositorID(aID); - } - - Compositor* GetCompositor() const - { - return mCompositor; - } - -protected: - ShadowLayerManager() - : mCompositor(nullptr) - {} - - bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface); - RefPtr mCompositor; -}; - class CompositableClient; /** @@ -526,199 +461,6 @@ protected: PLayerChild* mShadow; }; -/** - * A ShadowLayer is the representation of a child-context's Layer in a - * parent context. They can be transformed, clipped, - * etc. independently of their origin Layers. - * - * Note that ShadowLayers can themselves have a shadow in a parent - * context. - */ -class ShadowLayer -{ -public: - virtual ~ShadowLayer() {} - - virtual void DestroyFrontBuffer() { } - - /** - * The following methods are - * - * CONSTRUCTION PHASE ONLY - * - * They are analogous to the Layer interface. - */ - void SetShadowVisibleRegion(const nsIntRegion& aRegion) - { - mShadowVisibleRegion = aRegion; - } - - void SetShadowOpacity(float aOpacity) - { - mShadowOpacity = aOpacity; - } - - void SetShadowClipRect(const nsIntRect* aRect) - { - mUseShadowClipRect = aRect != nullptr; - if (aRect) { - mShadowClipRect = *aRect; - } - } - - void SetShadowTransform(const gfx3DMatrix& aMatrix) - { - mShadowTransform = aMatrix; - } - - // These getters can be used anytime. - float GetShadowOpacity() { return mShadowOpacity; } - const nsIntRect* GetShadowClipRect() { return mUseShadowClipRect ? &mShadowClipRect : nullptr; } - const nsIntRegion& GetShadowVisibleRegion() { return mShadowVisibleRegion; } - const gfx3DMatrix& GetShadowTransform() { return mShadowTransform; } - -protected: - ShadowLayer() - : mShadowOpacity(1.0f) - , mUseShadowClipRect(false) - {} - - nsIntRegion mShadowVisibleRegion; - gfx3DMatrix mShadowTransform; - nsIntRect mShadowClipRect; - float mShadowOpacity; - bool mUseShadowClipRect; -}; - - -class ShadowThebesLayer : public ShadowLayer, - public ThebesLayer -{ -public: - virtual void InvalidateRegion(const nsIntRegion& aRegion) - { - NS_RUNTIMEABORT("ShadowThebesLayers can't fill invalidated regions"); - } - - /** - * CONSTRUCTION PHASE ONLY - */ - virtual void SetValidRegion(const nsIntRegion& aRegion) - { - MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ValidRegion", this)); - mValidRegion = aRegion; - Mutated(); - } - - const nsIntRegion& GetValidRegion() { return mValidRegion; } - - virtual void - Swap(const ThebesBuffer& aNewFront, const nsIntRegion& aUpdatedRegion, - OptionalThebesBuffer* aNewBack, nsIntRegion* aNewBackValidRegion, - OptionalThebesBuffer* aReadOnlyFront, nsIntRegion* aFrontUpdatedRegion) { - NS_RUNTIMEABORT("should not use layer swap"); - }; - - virtual ShadowLayer* AsShadowLayer() { return this; } - - MOZ_LAYER_DECL_NAME("ShadowThebesLayer", TYPE_SHADOW) - -protected: - ShadowThebesLayer(LayerManager* aManager, void* aImplData) - : ThebesLayer(aManager, aImplData) - {} -}; - - -class ShadowContainerLayer : public ShadowLayer, - public ContainerLayer -{ -public: - virtual ShadowLayer* AsShadowLayer() { return this; } - - MOZ_LAYER_DECL_NAME("ShadowContainerLayer", TYPE_SHADOW) - -protected: - ShadowContainerLayer(LayerManager* aManager, void* aImplData) - : ContainerLayer(aManager, aImplData) - {} -}; - - -class ShadowCanvasLayer : public ShadowLayer, - public CanvasLayer -{ -public: - /** - * CONSTRUCTION PHASE ONLY - * - * Publish the remote layer's back surface to this shadow, swapping - * out the old front surface (the new back surface for the remote - * layer). - */ - virtual void Swap(const SurfaceDescriptor& aNewFront, bool needYFlip, - SurfaceDescriptor* aNewBack) = 0; - - virtual ShadowLayer* AsShadowLayer() { return this; } - - void SetBounds(nsIntRect aBounds) { mBounds = aBounds; } - - MOZ_LAYER_DECL_NAME("ShadowCanvasLayer", TYPE_SHADOW) - -protected: - ShadowCanvasLayer(LayerManager* aManager, void* aImplData) - : CanvasLayer(aManager, aImplData) - {} -}; - - -class ShadowImageLayer : public ShadowLayer, - public ImageLayer -{ -public: - /** - * CONSTRUCTION PHASE ONLY - * @see ShadowCanvasLayer::Swap - */ - virtual ShadowLayer* AsShadowLayer() { return this; } - - MOZ_LAYER_DECL_NAME("ShadowImageLayer", TYPE_SHADOW) - -protected: - ShadowImageLayer(LayerManager* aManager, void* aImplData) - : ImageLayer(aManager, aImplData) - {} -}; - - -class ShadowColorLayer : public ShadowLayer, - public ColorLayer -{ -public: - virtual ShadowLayer* AsShadowLayer() { return this; } - - MOZ_LAYER_DECL_NAME("ShadowColorLayer", TYPE_SHADOW) - -protected: - ShadowColorLayer(LayerManager* aManager, void* aImplData) - : ColorLayer(aManager, aImplData) - {} -}; - -class ShadowRefLayer : public ShadowLayer, - public RefLayer -{ -public: - virtual ShadowLayer* AsShadowLayer() { return this; } - - MOZ_LAYER_DECL_NAME("ShadowRefLayer", TYPE_SHADOW) - -protected: - ShadowRefLayer(LayerManager* aManager, void* aImplData) - : RefLayer(aManager, aImplData) - {} -}; - } // namespace layers } // namespace mozilla diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 47da91f65d8b..6153f43afdcb 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -14,7 +14,6 @@ EXPORTS += [ 'BasicTiledThebesLayer.h', 'BasicThebesLayer.h', 'CompositableHost.h', - 'LayerManagerComposite.h', 'Composer2D.h', 'GonkIOSurfaceImage.h', 'FrameMetrics.h', @@ -62,11 +61,14 @@ EXPORTS.mozilla.layers += [ 'AsyncPanZoomController.h', 'Axis.h', 'CanvasClient.h', + 'CanvasLayerComposite.h', + 'ColorLayerComposite.h', 'CompositableClient.h', 'CompositableTransactionParent.h', 'Compositor.h', 'CompositorOGL.h', 'CompositorTypes.h', + 'ContainerLayerComposite.h', 'ContentHost.h', 'CompositingRenderTargetOGL.h', 'CompositorCocoaWidgetHelper.h', @@ -80,12 +82,14 @@ EXPORTS.mozilla.layers += [ 'ImageBridgeChild.h', 'ImageBridgeParent.h', 'ImageClient.h', + 'ImageLayerComposite.h', 'ImageHost.h', 'ISurfaceAllocator.h', + 'LayerManagerComposite.h', 'LayersTypes.h', - 'ShadowLayers.h', 'LayerTransactionChild.h', 'LayerTransactionParent.h', + 'ShadowLayers.h', 'ShadowLayersManager.h', 'RenderTrace.h', 'SharedRGBImage.h', @@ -96,6 +100,7 @@ EXPORTS.mozilla.layers += [ 'TextureHost.h', 'TextureClientOGL.h', 'TextureHostOGL.h', + 'ThebesLayerComposite.h', 'TiledContentClient.h', ] diff --git a/gfx/layers/opengl/GLManager.cpp b/gfx/layers/opengl/GLManager.cpp index 7a4723be035a..299affee007f 100644 --- a/gfx/layers/opengl/GLManager.cpp +++ b/gfx/layers/opengl/GLManager.cpp @@ -1,7 +1,7 @@ #include "GLManager.h" #include "LayerManagerOGL.h" #include "CompositorOGL.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "GLContext.h" using namespace mozilla::gl; diff --git a/gfx/layers/opengl/LayerManagerOGL.h b/gfx/layers/opengl/LayerManagerOGL.h index 6d05f2cf573d..e714d3990d5f 100644 --- a/gfx/layers/opengl/LayerManagerOGL.h +++ b/gfx/layers/opengl/LayerManagerOGL.h @@ -32,11 +32,11 @@ namespace layers { class Composer2D; class LayerOGL; -class ShadowThebesLayer; -class ShadowContainerLayer; -class ShadowImageLayer; -class ShadowCanvasLayer; -class ShadowColorLayer; +class ThebesLayerComposite; +class ContainerLayerComposite; +class ImageLayerComposite; +class CanvasLayerComposite; +class ColorLayerComposite; struct FPSState; /** diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index fd3460a247ae..b920715a5f5f 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -254,7 +254,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader, float aTempScaleDiffX = 1.0, float aTempScaleDiffY = 1.0) { - ShadowLayer* shadow = aLayer->AsShadowLayer(); + LayerComposite* shadow = aLayer->AsLayerComposite(); shadow->SetShadowClipRect(aLayer->GetClipRect()); shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion()); shadow->SetShadowOpacity(aLayer->GetOpacity()); @@ -435,7 +435,7 @@ BuildBackgroundPatternFor(ContainerLayer* aContainer, LayerManager* aManager, nsIFrame* aFrame) { - ShadowLayer* shadowRoot = aShadowRoot->AsShadowLayer(); + LayerComposite* shadowRoot = aShadowRoot->AsLayerComposite(); gfxMatrix t; if (!shadowRoot->GetShadowTransform().Is2D(&t)) { return; @@ -603,7 +603,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, nsRefPtr lm = GetFrom(mFrameLoader); // Perhaps the document containing this frame currently has no presentation? - if (lm && lm->AsShadowManager()) { + if (lm && lm->AsLayerManagerComposite()) { *aTextureFactoryIdentifier = lm->GetTextureFactoryIdentifier(); } else { *aTextureFactoryIdentifier = TextureFactoryIdentifier(); @@ -853,7 +853,7 @@ RenderFrameParent::AllocPLayerTransaction() return nullptr; } nsRefPtr lm = GetFrom(mFrameLoader); - return new LayerTransactionParent(lm->AsShadowManager(), this, 0); + return new LayerTransactionParent(lm->AsLayerManagerComposite(), this, 0); } bool diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 32f88e2fb892..2e396b46cb7f 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -39,7 +39,7 @@ using mozilla::unused; #include "Layers.h" #include "BasicLayers.h" #include "LayerManagerOGL.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "GLContext.h" #include "GLContextProvider.h" diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index e45828d168f4..5fd7543b0af5 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -51,7 +51,7 @@ #include "nsRegion.h" #include "Layers.h" #include "LayerManagerOGL.h" -#include "LayerManagerComposite.h" +#include "mozilla/layers/LayerManagerComposite.h" #include "GLTextureImage.h" #include "mozilla/layers/GLManager.h" #include "mozilla/layers/CompositorCocoaWidgetHelper.h" @@ -2842,7 +2842,7 @@ NSEvent* gLastDragMouseDownEvent = nil; // Mac OS X bug that stops windows updating on OS X when we use OpenGL. LayerManager *layerManager = mGeckoChild->GetLayerManager(nullptr); if (mUsingOMTCompositor && painted && !mDidForceRefreshOpenGL && - layerManager->AsShadowManager()) { + layerManager->AsLayerManagerComposite()) { if (!mDidForceRefreshOpenGL) { [self performSelector:@selector(forceRefreshOpenGL) withObject:nil afterDelay:0]; mDidForceRefreshOpenGL = YES;