Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; 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 mozilla_gfx_layers_mlgpu_ContainerLayerMLGPU_h
7 : #define mozilla_gfx_layers_mlgpu_ContainerLayerMLGPU_h
8 :
9 : #include "LayerMLGPU.h"
10 : #include "MLGDeviceTypes.h"
11 :
12 : namespace mozilla {
13 : namespace layers {
14 :
15 : class MLGDevice;
16 :
17 : class ContainerLayerMLGPU final : public ContainerLayer
18 : , public LayerMLGPU
19 : {
20 : public:
21 : explicit ContainerLayerMLGPU(LayerManagerMLGPU* aManager);
22 : ~ContainerLayerMLGPU() override;
23 :
24 0 : MOZ_LAYER_DECL_NAME("ContainerLayerMLGPU", TYPE_CONTAINER)
25 :
26 0 : HostLayer* AsHostLayer() override { return this; }
27 0 : ContainerLayerMLGPU* AsContainerLayerMLGPU() override { return this; }
28 0 : Layer* GetLayer() override { return this; }
29 :
30 0 : void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override {
31 0 : DefaultComputeEffectiveTransforms(aTransformToSurface);
32 0 : }
33 : void SetInvalidCompositeRect(const gfx::IntRect &aRect) override;
34 : void ClearCachedResources() override;
35 :
36 : RefPtr<MLGRenderTarget> UpdateRenderTarget(
37 : MLGDevice* aDevice,
38 : MLGRenderTargetFlags aFlags);
39 :
40 0 : MLGRenderTarget* GetRenderTarget() const {
41 0 : return mRenderTarget;
42 : }
43 0 : gfx::IntPoint GetTargetOffset() const {
44 0 : return mTargetOffset;
45 : }
46 0 : gfx::IntSize GetTargetSize() const {
47 0 : return mTargetSize;
48 : }
49 0 : const gfx::IntRect& GetInvalidRect() const {
50 0 : return mInvalidRect;
51 : }
52 0 : void ClearInvalidRect() {
53 0 : mInvalidRect.SetEmpty();
54 0 : }
55 : bool IsContentOpaque() override;
56 :
57 : protected:
58 : bool OnPrepareToRender(FrameBuilder* aBuilder) override;
59 : void OnLayerManagerChange(LayerManagerMLGPU* aManager) override;
60 : Maybe<gfx::IntRect> ComputeIntermediateSurfaceBounds();
61 :
62 : private:
63 : RefPtr<MLGRenderTarget> mRenderTarget;
64 :
65 : // We cache these since occlusion culling can change the visible region.
66 : gfx::IntPoint mTargetOffset;
67 : gfx::IntSize mTargetSize;
68 :
69 : // The region of the container that needs to be recomposited if visible. We
70 : // store this as a rectangle instead of an nsIntRegion for efficiency.
71 : gfx::IntRect mInvalidRect;
72 : };
73 :
74 : } // namespace layers
75 : } // namespace mozilla
76 :
77 : #endif // mozilla_gfx_layers_mlgpu_ContainerLayerMLGPU_h
|