gfx/layers/basic/BasicContainerLayer.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:213a35153e0c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef GFX_BASICCONTAINERLAYER_H
7 #define GFX_BASICCONTAINERLAYER_H
8
9 #include "BasicImplData.h" // for BasicImplData
10 #include "BasicLayers.h" // for BasicLayerManager
11 #include "Layers.h" // for Layer, ContainerLayer
12 #include "nsDebug.h" // for NS_ASSERTION
13 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR
14 #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE
15 struct nsIntRect;
16
17 namespace mozilla {
18 namespace layers {
19
20 class BasicContainerLayer : public ContainerLayer, public BasicImplData {
21 public:
22 BasicContainerLayer(BasicLayerManager* aManager) :
23 ContainerLayer(aManager,
24 static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
25 {
26 MOZ_COUNT_CTOR(BasicContainerLayer);
27 mSupportsComponentAlphaChildren = true;
28 }
29 virtual ~BasicContainerLayer();
30
31 virtual void SetVisibleRegion(const nsIntRegion& aRegion)
32 {
33 NS_ASSERTION(BasicManager()->InConstruction(),
34 "Can only set properties in construction phase");
35 ContainerLayer::SetVisibleRegion(aRegion);
36 }
37 virtual bool InsertAfter(Layer* aChild, Layer* aAfter)
38 {
39 if (!BasicManager()->InConstruction()) {
40 NS_ERROR("Can only set properties in construction phase");
41 return false;
42 }
43 return ContainerLayer::InsertAfter(aChild, aAfter);
44 }
45
46 virtual bool RemoveChild(Layer* aChild)
47 {
48 if (!BasicManager()->InConstruction()) {
49 NS_ERROR("Can only set properties in construction phase");
50 return false;
51 }
52 return ContainerLayer::RemoveChild(aChild);
53 }
54
55 virtual bool RepositionChild(Layer* aChild, Layer* aAfter)
56 {
57 if (!BasicManager()->InConstruction()) {
58 NS_ERROR("Can only set properties in construction phase");
59 return false;
60 }
61 return ContainerLayer::RepositionChild(aChild, aAfter);
62 }
63
64 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface);
65
66 /**
67 * Returns true when:
68 * a) no (non-hidden) childrens' visible areas overlap in
69 * (aInRect intersected with this layer's visible region).
70 * b) the (non-hidden) childrens' visible areas cover
71 * (aInRect intersected with this layer's visible region).
72 * c) this layer and all (non-hidden) children have transforms that are translations
73 * by integers.
74 * aInRect is in the root coordinate system.
75 * Child layers with opacity do not contribute to the covered area in check b).
76 * This method can be conservative; it's OK to return false under any
77 * circumstances.
78 */
79 bool ChildrenPartitionVisibleRegion(const nsIntRect& aInRect);
80
81 void ForceIntermediateSurface() { mUseIntermediateSurface = true; }
82
83 void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; }
84
85 virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback,
86 void* aCallbackData) MOZ_OVERRIDE;
87
88 protected:
89 BasicLayerManager* BasicManager()
90 {
91 return static_cast<BasicLayerManager*>(mManager);
92 }
93 };
94 }
95 }
96
97 #endif

mercurial