/src/mozilla-central/gfx/layers/basic/BasicContainerLayer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef GFX_BASICCONTAINERLAYER_H |
8 | | #define GFX_BASICCONTAINERLAYER_H |
9 | | |
10 | | #include "BasicImplData.h" // for BasicImplData |
11 | | #include "BasicLayers.h" // for BasicLayerManager |
12 | | #include "Layers.h" // for Layer, ContainerLayer |
13 | | #include "nsDebug.h" // for NS_ASSERTION |
14 | | #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR |
15 | | #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE |
16 | | #include "mozilla/gfx/Rect.h" |
17 | | |
18 | | namespace mozilla { |
19 | | namespace layers { |
20 | | |
21 | | class BasicContainerLayer : public ContainerLayer, public BasicImplData { |
22 | | public: |
23 | | explicit BasicContainerLayer(BasicLayerManager* aManager) : |
24 | | ContainerLayer(aManager, static_cast<BasicImplData*>(this)) |
25 | 0 | { |
26 | 0 | MOZ_COUNT_CTOR(BasicContainerLayer); |
27 | 0 | mSupportsComponentAlphaChildren = true; |
28 | 0 | } |
29 | | protected: |
30 | | virtual ~BasicContainerLayer(); |
31 | | |
32 | | public: |
33 | | virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override |
34 | 0 | { |
35 | 0 | NS_ASSERTION(BasicManager()->InConstruction(), |
36 | 0 | "Can only set properties in construction phase"); |
37 | 0 | ContainerLayer::SetVisibleRegion(aRegion); |
38 | 0 | } |
39 | | virtual bool InsertAfter(Layer* aChild, Layer* aAfter) override |
40 | 0 | { |
41 | 0 | if (!BasicManager()->InConstruction()) { |
42 | 0 | NS_ERROR("Can only set properties in construction phase"); |
43 | 0 | return false; |
44 | 0 | } |
45 | 0 | return ContainerLayer::InsertAfter(aChild, aAfter); |
46 | 0 | } |
47 | | |
48 | | virtual bool RemoveChild(Layer* aChild) override |
49 | 0 | { |
50 | 0 | if (!BasicManager()->InConstruction()) { |
51 | 0 | NS_ERROR("Can only set properties in construction phase"); |
52 | 0 | return false; |
53 | 0 | } |
54 | 0 | return ContainerLayer::RemoveChild(aChild); |
55 | 0 | } |
56 | | |
57 | | virtual bool RepositionChild(Layer* aChild, Layer* aAfter) override |
58 | 0 | { |
59 | 0 | if (!BasicManager()->InConstruction()) { |
60 | 0 | NS_ERROR("Can only set properties in construction phase"); |
61 | 0 | return false; |
62 | 0 | } |
63 | 0 | return ContainerLayer::RepositionChild(aChild, aAfter); |
64 | 0 | } |
65 | | |
66 | | virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override; |
67 | | |
68 | | /** |
69 | | * Returns true when: |
70 | | * a) no (non-hidden) childrens' visible areas overlap in |
71 | | * (aInRect intersected with this layer's visible region). |
72 | | * b) the (non-hidden) childrens' visible areas cover |
73 | | * (aInRect intersected with this layer's visible region). |
74 | | * c) this layer and all (non-hidden) children have transforms that are translations |
75 | | * by integers. |
76 | | * aInRect is in the root coordinate system. |
77 | | * Child layers with opacity do not contribute to the covered area in check b). |
78 | | * This method can be conservative; it's OK to return false under any |
79 | | * circumstances. |
80 | | */ |
81 | | bool ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect); |
82 | | |
83 | 0 | void ForceIntermediateSurface() { mUseIntermediateSurface = true; } |
84 | | |
85 | 0 | void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; } |
86 | | |
87 | | virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback, |
88 | | void* aCallbackData, |
89 | | ReadbackProcessor* aReadback) override; |
90 | | |
91 | | /** |
92 | | * We don't really have a hard restriction for max layer size, but we pick |
93 | | * 4096 to avoid excessive memory usage. |
94 | | */ |
95 | 0 | virtual int32_t GetMaxLayerSize() override { return 4096; } |
96 | | |
97 | | protected: |
98 | | BasicLayerManager* BasicManager() |
99 | 0 | { |
100 | 0 | return static_cast<BasicLayerManager*>(mManager); |
101 | 0 | } |
102 | | }; |
103 | | |
104 | | } // namespace layers |
105 | | } // namespace mozilla |
106 | | |
107 | | #endif |