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_CanvasLayerComposite_H 8 #define GFX_CanvasLayerComposite_H 9 10 #include "Layers.h" // for CanvasLayer, etc 11 #include "mozilla/Attributes.h" // for override 12 #include "mozilla/RefPtr.h" // for RefPtr 13 #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc 14 #include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc 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, public LayerComposite { 27 public: 28 explicit CanvasLayerComposite(LayerManagerComposite* aManager); 29 30 protected: 31 virtual ~CanvasLayerComposite(); 32 33 public: 34 bool SetCompositableHost(CompositableHost* aHost) override; 35 Disconnect()36 void Disconnect() override { Destroy(); } 37 38 void SetLayerManager(HostLayerManager* aManager) override; 39 40 Layer* GetLayer() override; 41 void RenderLayer(const gfx::IntRect& aClipRect, 42 const Maybe<gfx::Polygon>& aGeometry) override; 43 44 void CleanupResources() override; 45 46 void GenEffectChain(EffectChain& aEffect) override; 47 48 CompositableHost* GetCompositableHost() override; 49 AsHostLayer()50 HostLayer* AsHostLayer() override { return this; } 51 Name()52 const char* Name() const override { return "CanvasLayerComposite"; } 53 54 protected: CreateCanvasRendererInternal()55 RefPtr<CanvasRenderer> CreateCanvasRendererInternal() override { 56 MOZ_CRASH("Incompatible surface type"); 57 return nullptr; 58 } 59 60 void PrintInfo(std::stringstream& aStream, const char* aPrefix) override; 61 62 private: 63 gfx::SamplingFilter GetSamplingFilter(); 64 65 private: 66 RefPtr<CompositableHost> mCompositableHost; 67 }; 68 69 } // namespace layers 70 } // namespace mozilla 71 72 #endif /* GFX_CanvasLayerComposite_H */ 73