1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/ImageLayers.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_IMAGELAYER_H 1.10 +#define GFX_IMAGELAYER_H 1.11 + 1.12 +#include "Layers.h" // for Layer, etc 1.13 +#include "GraphicsFilter.h" // for GraphicsFilter 1.14 +#include "mozilla/gfx/BaseSize.h" // for BaseSize 1.15 +#include "mozilla/gfx/Point.h" // for IntSize 1.16 +#include "mozilla/layers/LayersTypes.h" 1.17 +#include "nsAutoPtr.h" // for nsRefPtr 1.18 +#include "nscore.h" // for nsACString 1.19 + 1.20 +namespace mozilla { 1.21 +namespace layers { 1.22 + 1.23 +class ImageContainer; 1.24 + 1.25 +/** 1.26 + * A Layer which renders an Image. 1.27 + */ 1.28 +class ImageLayer : public Layer { 1.29 +public: 1.30 + /** 1.31 + * CONSTRUCTION PHASE ONLY 1.32 + * Set the ImageContainer. aContainer must have the same layer manager 1.33 + * as this layer. 1.34 + */ 1.35 + virtual void SetContainer(ImageContainer* aContainer); 1.36 + 1.37 + /** 1.38 + * CONSTRUCTION PHASE ONLY 1.39 + * Set the filter used to resample this image if necessary. 1.40 + */ 1.41 + void SetFilter(GraphicsFilter aFilter) 1.42 + { 1.43 + if (mFilter != aFilter) { 1.44 + MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this)); 1.45 + mFilter = aFilter; 1.46 + Mutated(); 1.47 + } 1.48 + } 1.49 + 1.50 + /** 1.51 + * CONSTRUCTION PHASE ONLY 1.52 + * Set the size to scale the image to and the mode at which to scale. 1.53 + */ 1.54 + void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode) 1.55 + { 1.56 + if (mScaleToSize != aSize || mScaleMode != aMode) { 1.57 + mScaleToSize = aSize; 1.58 + mScaleMode = aMode; 1.59 + Mutated(); 1.60 + } 1.61 + } 1.62 + 1.63 + 1.64 + ImageContainer* GetContainer() { return mContainer; } 1.65 + GraphicsFilter GetFilter() { return mFilter; } 1.66 + const gfx::IntSize& GetScaleToSize() { return mScaleToSize; } 1.67 + ScaleMode GetScaleMode() { return mScaleMode; } 1.68 + 1.69 + MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE) 1.70 + 1.71 + virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface); 1.72 + 1.73 + /** 1.74 + * if true, the image will only be backed by a single tile texture 1.75 + */ 1.76 + void SetDisallowBigImage(bool aDisallowBigImage) 1.77 + { 1.78 + if (mDisallowBigImage != aDisallowBigImage) { 1.79 + MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this)); 1.80 + mDisallowBigImage = aDisallowBigImage; 1.81 + Mutated(); 1.82 + } 1.83 + } 1.84 + 1.85 +protected: 1.86 + ImageLayer(LayerManager* aManager, void* aImplData); 1.87 + ~ImageLayer(); 1.88 + virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix); 1.89 + 1.90 + 1.91 + nsRefPtr<ImageContainer> mContainer; 1.92 + GraphicsFilter mFilter; 1.93 + gfx::IntSize mScaleToSize; 1.94 + ScaleMode mScaleMode; 1.95 + bool mDisallowBigImage; 1.96 +}; 1.97 + 1.98 +} 1.99 +} 1.100 + 1.101 +#endif /* GFX_IMAGELAYER_H */