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 GFX_CanvasLayerComposite_H
7 : #define GFX_CanvasLayerComposite_H
8 :
9 : #include "Layers.h" // for CanvasLayer, etc
10 : #include "mozilla/Attributes.h" // for override
11 : #include "mozilla/RefPtr.h" // for RefPtr
12 : #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc
13 : #include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
14 : #include "nsDebug.h" // for NS_RUNTIMEABORT
15 : #include "nsRect.h" // for mozilla::gfx::IntRect
16 : #include "nscore.h" // for nsACString
17 :
18 : namespace mozilla {
19 : namespace layers {
20 :
21 : class CompositableHost;
22 : // Canvas layers use ImageHosts (but CanvasClients) because compositing a
23 : // canvas is identical to compositing an image.
24 : class ImageHost;
25 :
26 : class CanvasLayerComposite : public CanvasLayer,
27 : public LayerComposite
28 : {
29 : public:
30 : explicit CanvasLayerComposite(LayerManagerComposite* aManager);
31 :
32 : protected:
33 : virtual ~CanvasLayerComposite();
34 :
35 : public:
36 : // CanvasLayer impl
37 0 : virtual void Initialize(const Data& aData) override
38 : {
39 0 : MOZ_CRASH("Incompatibe surface type");
40 : }
41 :
42 : virtual bool SetCompositableHost(CompositableHost* aHost) override;
43 :
44 0 : virtual void Disconnect() override
45 : {
46 0 : Destroy();
47 0 : }
48 :
49 : virtual void SetLayerManager(HostLayerManager* aManager) override;
50 :
51 : virtual Layer* GetLayer() override;
52 : virtual void RenderLayer(const gfx::IntRect& aClipRect,
53 : const Maybe<gfx::Polygon>& aGeometry) override;
54 :
55 : virtual void CleanupResources() override;
56 :
57 : virtual void GenEffectChain(EffectChain& aEffect) override;
58 :
59 : CompositableHost* GetCompositableHost() override;
60 :
61 0 : virtual HostLayer* AsHostLayer() override { return this; }
62 :
63 0 : virtual const char* Name() const override { return "CanvasLayerComposite"; }
64 :
65 : protected:
66 : virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
67 :
68 : private:
69 : gfx::SamplingFilter GetSamplingFilter();
70 :
71 : private:
72 : RefPtr<CompositableHost> mCompositableHost;
73 : };
74 :
75 : } // namespace layers
76 : } // namespace mozilla
77 :
78 : #endif /* GFX_CanvasLayerComposite_H */
|