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_PaintedLayerComposite_H 8 #define GFX_PaintedLayerComposite_H 9 10 #include "Layers.h" // for Layer (ptr only), etc 11 #include "mozilla/gfx/Rect.h" 12 #include "mozilla/Attributes.h" // for override 13 #include "mozilla/RefPtr.h" // for RefPtr 14 #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc 15 #include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc 16 #include "nsRegion.h" // for nsIntRegion 17 #include "nscore.h" // for nsACString 18 19 namespace mozilla { 20 namespace layers { 21 22 /** 23 * PaintedLayers use ContentHosts for their compsositable host. 24 * By using different ContentHosts, PaintedLayerComposite support tiled and 25 * non-tiled PaintedLayers and single or double buffering. 26 */ 27 28 class CompositableHost; 29 class ContentHost; 30 31 class PaintedLayerComposite : public PaintedLayer, public LayerComposite { 32 public: 33 explicit PaintedLayerComposite(LayerManagerComposite* aManager); 34 35 protected: 36 virtual ~PaintedLayerComposite(); 37 38 public: 39 virtual void Disconnect() override; 40 41 CompositableHost* GetCompositableHost() override; 42 43 virtual void Destroy() override; 44 45 virtual Layer* GetLayer() override; 46 47 virtual void SetLayerManager(HostLayerManager* aManager) override; 48 49 virtual void RenderLayer(const gfx::IntRect& aClipRect, 50 const Maybe<gfx::Polygon>& aGeometry) override; 51 52 virtual void CleanupResources() override; 53 54 virtual bool IsOpaque() override; 55 56 virtual void GenEffectChain(EffectChain& aEffect) override; 57 58 virtual bool SetCompositableHost(CompositableHost* aHost) override; 59 AsHostLayer()60 virtual HostLayer* AsHostLayer() override { return this; } 61 InvalidateRegion(const nsIntRegion & aRegion)62 virtual void InvalidateRegion(const nsIntRegion& aRegion) override { 63 MOZ_CRASH("PaintedLayerComposites can't fill invalidated regions"); 64 } 65 66 const virtual gfx::TiledIntRegion& GetInvalidRegion() override; 67 68 MOZ_LAYER_DECL_NAME("PaintedLayerComposite", TYPE_PAINTED) 69 70 protected: 71 virtual void PrintInfo(std::stringstream& aStream, 72 const char* aPrefix) override; 73 74 private: GetSamplingFilter()75 gfx::SamplingFilter GetSamplingFilter() { 76 return gfx::SamplingFilter::LINEAR; 77 } 78 79 private: 80 RefPtr<ContentHost> mBuffer; 81 }; 82 83 } // namespace layers 84 } // namespace mozilla 85 86 #endif /* GFX_PaintedLayerComposite_H */ 87