Line data Source code
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/. */
5 :
6 : #ifndef GFX_IMAGELAYER_H
7 : #define GFX_IMAGELAYER_H
8 :
9 : #include "Layers.h" // for Layer, etc
10 : #include "mozilla/gfx/BaseSize.h" // for BaseSize
11 : #include "mozilla/gfx/Point.h" // for IntSize
12 : #include "mozilla/layers/LayersTypes.h"
13 : #include "nsAutoPtr.h" // for nsRefPtr
14 : #include "nscore.h" // for nsACString
15 :
16 : namespace mozilla {
17 : namespace layers {
18 :
19 : class ImageContainer;
20 :
21 : namespace layerscope {
22 : class LayersPacket;
23 : } // namespace layerscope
24 :
25 : /**
26 : * A Layer which renders an Image.
27 : */
28 : class ImageLayer : public Layer {
29 : public:
30 : /**
31 : * CONSTRUCTION PHASE ONLY
32 : * Set the ImageContainer. aContainer must have the same layer manager
33 : * as this layer.
34 : */
35 : virtual void SetContainer(ImageContainer* aContainer);
36 :
37 : /**
38 : * CONSTRUCTION PHASE ONLY
39 : * Set the filter used to resample this image if necessary.
40 : */
41 0 : void SetSamplingFilter(gfx::SamplingFilter aSamplingFilter)
42 : {
43 0 : if (mSamplingFilter != aSamplingFilter) {
44 0 : MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
45 0 : mSamplingFilter = aSamplingFilter;
46 0 : Mutated();
47 : }
48 0 : }
49 :
50 : /**
51 : * CONSTRUCTION PHASE ONLY
52 : * Set the size to scale the image to and the mode at which to scale.
53 : */
54 0 : void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode)
55 : {
56 0 : if (mScaleToSize != aSize || mScaleMode != aMode) {
57 0 : mScaleToSize = aSize;
58 0 : mScaleMode = aMode;
59 0 : Mutated();
60 : }
61 0 : }
62 :
63 :
64 0 : ImageContainer* GetContainer() { return mContainer; }
65 0 : gfx::SamplingFilter GetSamplingFilter() { return mSamplingFilter; }
66 0 : const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
67 0 : ScaleMode GetScaleMode() { return mScaleMode; }
68 :
69 0 : MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
70 :
71 : virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override;
72 :
73 0 : virtual const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const override
74 : {
75 0 : return mEffectiveTransformForBuffer;
76 : }
77 :
78 0 : virtual ImageLayer* AsImageLayer() override { return this; }
79 :
80 : protected:
81 : ImageLayer(LayerManager* aManager, void* aImplData);
82 : ~ImageLayer();
83 : virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
84 : virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
85 :
86 : RefPtr<ImageContainer> mContainer;
87 : gfx::SamplingFilter mSamplingFilter;
88 : gfx::IntSize mScaleToSize;
89 : ScaleMode mScaleMode;
90 : gfx::Matrix4x4 mEffectiveTransformForBuffer;
91 : };
92 :
93 : } // namespace layers
94 : } // namespace mozilla
95 :
96 : #endif /* GFX_IMAGELAYER_H */
|