Bumping manifests a=b2g-bump
[gecko.git] / gfx / layers / ImageLayers.h
blobe7b0913ca21080c4cc32e66721cc432787ea7665
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/. */
6 #ifndef GFX_IMAGELAYER_H
7 #define GFX_IMAGELAYER_H
9 #include "Layers.h" // for Layer, etc
10 #include "GraphicsFilter.h" // for GraphicsFilter
11 #include "mozilla/gfx/BaseSize.h" // for BaseSize
12 #include "mozilla/gfx/Point.h" // for IntSize
13 #include "mozilla/layers/LayersTypes.h"
14 #include "nsAutoPtr.h" // for nsRefPtr
15 #include "nscore.h" // for nsACString
17 namespace mozilla {
18 namespace layers {
20 class ImageContainer;
22 namespace layerscope {
23 class LayersPacket;
26 /**
27 * A Layer which renders an Image.
29 class ImageLayer : public Layer {
30 public:
31 /**
32 * CONSTRUCTION PHASE ONLY
33 * Set the ImageContainer. aContainer must have the same layer manager
34 * as this layer.
36 virtual void SetContainer(ImageContainer* aContainer);
38 /**
39 * CONSTRUCTION PHASE ONLY
40 * Set the filter used to resample this image if necessary.
42 void SetFilter(GraphicsFilter aFilter)
44 if (mFilter != aFilter) {
45 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
46 mFilter = aFilter;
47 Mutated();
51 /**
52 * CONSTRUCTION PHASE ONLY
53 * Set the size to scale the image to and the mode at which to scale.
55 void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode)
57 if (mScaleToSize != aSize || mScaleMode != aMode) {
58 mScaleToSize = aSize;
59 mScaleMode = aMode;
60 Mutated();
65 ImageContainer* GetContainer() { return mContainer; }
66 GraphicsFilter GetFilter() { return mFilter; }
67 const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
68 ScaleMode GetScaleMode() { return mScaleMode; }
70 MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
72 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) MOZ_OVERRIDE;
74 virtual const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const MOZ_OVERRIDE
76 return mEffectiveTransformForBuffer;
79 /**
80 * if true, the image will only be backed by a single tile texture
82 void SetDisallowBigImage(bool aDisallowBigImage)
84 if (mDisallowBigImage != aDisallowBigImage) {
85 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this));
86 mDisallowBigImage = aDisallowBigImage;
87 Mutated();
91 protected:
92 ImageLayer(LayerManager* aManager, void* aImplData);
93 ~ImageLayer();
94 virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) MOZ_OVERRIDE;
95 virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) MOZ_OVERRIDE;
97 nsRefPtr<ImageContainer> mContainer;
98 GraphicsFilter mFilter;
99 gfx::IntSize mScaleToSize;
100 ScaleMode mScaleMode;
101 bool mDisallowBigImage;
102 gfx::Matrix4x4 mEffectiveTransformForBuffer;
108 #endif /* GFX_IMAGELAYER_H */