Line data Source code
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_WEBRENDERLAYER_H
7 : #define GFX_WEBRENDERLAYER_H
8 :
9 : #include "Layers.h"
10 : #include "mozilla/webrender/WebRenderTypes.h"
11 : #include "mozilla/webrender/WebRenderAPI.h"
12 :
13 : namespace mozilla {
14 : namespace layers {
15 :
16 : class ImageClientSingle;
17 : class StackingContextHelper;
18 : class WebRenderBridgeChild;
19 : class WebRenderLayerManager;
20 :
21 : typedef gfx::Matrix4x4Typed<LayerPixel, LayerPixel> BoundsTransformMatrix;
22 :
23 0 : class WebRenderLayer
24 : {
25 : public:
26 : virtual Layer* GetLayer() = 0;
27 : virtual void RenderLayer(wr::DisplayListBuilder& aBuilder,
28 : const StackingContextHelper& aSc) = 0;
29 0 : virtual Maybe<WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
30 : const gfx::Matrix4x4& aTransform)
31 : {
32 0 : MOZ_ASSERT(false);
33 : return Nothing();
34 : }
35 :
36 0 : virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
37 : static inline WebRenderLayer*
38 0 : ToWebRenderLayer(Layer* aLayer)
39 : {
40 0 : return static_cast<WebRenderLayer*>(aLayer->ImplData());
41 : }
42 :
43 : Maybe<wr::ImageKey> UpdateImageKey(ImageClientSingle* aImageClient,
44 : ImageContainer* aContainer,
45 : Maybe<wr::ImageKey>& aOldKey,
46 : wr::ExternalImageId& aExternalImageId);
47 :
48 : WebRenderLayerManager* WrManager();
49 : WebRenderBridgeChild* WrBridge();
50 : WrImageKey GetImageKey();
51 :
52 : LayerRect Bounds();
53 : LayerRect BoundsForStackingContext();
54 :
55 : // Builds a WrImageMask from the mask layer on this layer, if there is one.
56 : // The |aRelativeTo| parameter should be a reference to the stacking context
57 : // that we want this mask to be relative to. This is usually the stacking
58 : // context of the *parent* layer of |this|, because that is what the mask
59 : // is relative to in the layer tree.
60 : Maybe<WrImageMask> BuildWrMaskLayer(const StackingContextHelper& aRelativeTo);
61 :
62 : protected:
63 : BoundsTransformMatrix BoundsTransform();
64 :
65 : void DumpLayerInfo(const char* aLayerType, const LayerRect& aRect);
66 : };
67 :
68 : } // namespace layers
69 : } // namespace mozilla
70 :
71 : #endif /* GFX_WEBRENDERLAYER_H */
|