michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_BASICCONTAINERLAYER_H michael@0: #define GFX_BASICCONTAINERLAYER_H michael@0: michael@0: #include "BasicImplData.h" // for BasicImplData michael@0: #include "BasicLayers.h" // for BasicLayerManager michael@0: #include "Layers.h" // for Layer, ContainerLayer michael@0: #include "nsDebug.h" // for NS_ASSERTION michael@0: #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR michael@0: #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE michael@0: struct nsIntRect; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class BasicContainerLayer : public ContainerLayer, public BasicImplData { michael@0: public: michael@0: BasicContainerLayer(BasicLayerManager* aManager) : michael@0: ContainerLayer(aManager, michael@0: static_cast(MOZ_THIS_IN_INITIALIZER_LIST())) michael@0: { michael@0: MOZ_COUNT_CTOR(BasicContainerLayer); michael@0: mSupportsComponentAlphaChildren = true; michael@0: } michael@0: virtual ~BasicContainerLayer(); michael@0: michael@0: virtual void SetVisibleRegion(const nsIntRegion& aRegion) michael@0: { michael@0: NS_ASSERTION(BasicManager()->InConstruction(), michael@0: "Can only set properties in construction phase"); michael@0: ContainerLayer::SetVisibleRegion(aRegion); michael@0: } michael@0: virtual bool InsertAfter(Layer* aChild, Layer* aAfter) michael@0: { michael@0: if (!BasicManager()->InConstruction()) { michael@0: NS_ERROR("Can only set properties in construction phase"); michael@0: return false; michael@0: } michael@0: return ContainerLayer::InsertAfter(aChild, aAfter); michael@0: } michael@0: michael@0: virtual bool RemoveChild(Layer* aChild) michael@0: { michael@0: if (!BasicManager()->InConstruction()) { michael@0: NS_ERROR("Can only set properties in construction phase"); michael@0: return false; michael@0: } michael@0: return ContainerLayer::RemoveChild(aChild); michael@0: } michael@0: michael@0: virtual bool RepositionChild(Layer* aChild, Layer* aAfter) michael@0: { michael@0: if (!BasicManager()->InConstruction()) { michael@0: NS_ERROR("Can only set properties in construction phase"); michael@0: return false; michael@0: } michael@0: return ContainerLayer::RepositionChild(aChild, aAfter); michael@0: } michael@0: michael@0: virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface); michael@0: michael@0: /** michael@0: * Returns true when: michael@0: * a) no (non-hidden) childrens' visible areas overlap in michael@0: * (aInRect intersected with this layer's visible region). michael@0: * b) the (non-hidden) childrens' visible areas cover michael@0: * (aInRect intersected with this layer's visible region). michael@0: * c) this layer and all (non-hidden) children have transforms that are translations michael@0: * by integers. michael@0: * aInRect is in the root coordinate system. michael@0: * Child layers with opacity do not contribute to the covered area in check b). michael@0: * This method can be conservative; it's OK to return false under any michael@0: * circumstances. michael@0: */ michael@0: bool ChildrenPartitionVisibleRegion(const nsIntRect& aInRect); michael@0: michael@0: void ForceIntermediateSurface() { mUseIntermediateSurface = true; } michael@0: michael@0: void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; } michael@0: michael@0: virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, michael@0: void* aCallbackData) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: BasicLayerManager* BasicManager() michael@0: { michael@0: return static_cast(mManager); michael@0: } michael@0: }; michael@0: } michael@0: } michael@0: michael@0: #endif