michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_IMAGELAYER_H michael@0: #define GFX_IMAGELAYER_H michael@0: michael@0: #include "Layers.h" // for Layer, etc michael@0: #include "GraphicsFilter.h" // for GraphicsFilter michael@0: #include "mozilla/gfx/BaseSize.h" // for BaseSize michael@0: #include "mozilla/gfx/Point.h" // for IntSize michael@0: #include "mozilla/layers/LayersTypes.h" michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nscore.h" // for nsACString michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class ImageContainer; michael@0: michael@0: /** michael@0: * A Layer which renders an Image. michael@0: */ michael@0: class ImageLayer : public Layer { michael@0: public: michael@0: /** michael@0: * CONSTRUCTION PHASE ONLY michael@0: * Set the ImageContainer. aContainer must have the same layer manager michael@0: * as this layer. michael@0: */ michael@0: virtual void SetContainer(ImageContainer* aContainer); michael@0: michael@0: /** michael@0: * CONSTRUCTION PHASE ONLY michael@0: * Set the filter used to resample this image if necessary. michael@0: */ michael@0: void SetFilter(GraphicsFilter aFilter) michael@0: { michael@0: if (mFilter != aFilter) { michael@0: MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this)); michael@0: mFilter = aFilter; michael@0: Mutated(); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * CONSTRUCTION PHASE ONLY michael@0: * Set the size to scale the image to and the mode at which to scale. michael@0: */ michael@0: void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode) michael@0: { michael@0: if (mScaleToSize != aSize || mScaleMode != aMode) { michael@0: mScaleToSize = aSize; michael@0: mScaleMode = aMode; michael@0: Mutated(); michael@0: } michael@0: } michael@0: michael@0: michael@0: ImageContainer* GetContainer() { return mContainer; } michael@0: GraphicsFilter GetFilter() { return mFilter; } michael@0: const gfx::IntSize& GetScaleToSize() { return mScaleToSize; } michael@0: ScaleMode GetScaleMode() { return mScaleMode; } michael@0: michael@0: MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE) michael@0: michael@0: virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface); michael@0: michael@0: /** michael@0: * if true, the image will only be backed by a single tile texture michael@0: */ michael@0: void SetDisallowBigImage(bool aDisallowBigImage) michael@0: { michael@0: if (mDisallowBigImage != aDisallowBigImage) { michael@0: MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this)); michael@0: mDisallowBigImage = aDisallowBigImage; michael@0: Mutated(); michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: ImageLayer(LayerManager* aManager, void* aImplData); michael@0: ~ImageLayer(); michael@0: virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix); michael@0: michael@0: michael@0: nsRefPtr mContainer; michael@0: GraphicsFilter mFilter; michael@0: gfx::IntSize mScaleToSize; michael@0: ScaleMode mScaleMode; michael@0: bool mDisallowBigImage; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* GFX_IMAGELAYER_H */