|
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 "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 |
|
16 |
|
17 namespace mozilla { |
|
18 namespace layers { |
|
19 |
|
20 class ImageContainer; |
|
21 |
|
22 /** |
|
23 * A Layer which renders an Image. |
|
24 */ |
|
25 class ImageLayer : public Layer { |
|
26 public: |
|
27 /** |
|
28 * CONSTRUCTION PHASE ONLY |
|
29 * Set the ImageContainer. aContainer must have the same layer manager |
|
30 * as this layer. |
|
31 */ |
|
32 virtual void SetContainer(ImageContainer* aContainer); |
|
33 |
|
34 /** |
|
35 * CONSTRUCTION PHASE ONLY |
|
36 * Set the filter used to resample this image if necessary. |
|
37 */ |
|
38 void SetFilter(GraphicsFilter aFilter) |
|
39 { |
|
40 if (mFilter != aFilter) { |
|
41 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this)); |
|
42 mFilter = aFilter; |
|
43 Mutated(); |
|
44 } |
|
45 } |
|
46 |
|
47 /** |
|
48 * CONSTRUCTION PHASE ONLY |
|
49 * Set the size to scale the image to and the mode at which to scale. |
|
50 */ |
|
51 void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode) |
|
52 { |
|
53 if (mScaleToSize != aSize || mScaleMode != aMode) { |
|
54 mScaleToSize = aSize; |
|
55 mScaleMode = aMode; |
|
56 Mutated(); |
|
57 } |
|
58 } |
|
59 |
|
60 |
|
61 ImageContainer* GetContainer() { return mContainer; } |
|
62 GraphicsFilter GetFilter() { return mFilter; } |
|
63 const gfx::IntSize& GetScaleToSize() { return mScaleToSize; } |
|
64 ScaleMode GetScaleMode() { return mScaleMode; } |
|
65 |
|
66 MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE) |
|
67 |
|
68 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface); |
|
69 |
|
70 /** |
|
71 * if true, the image will only be backed by a single tile texture |
|
72 */ |
|
73 void SetDisallowBigImage(bool aDisallowBigImage) |
|
74 { |
|
75 if (mDisallowBigImage != aDisallowBigImage) { |
|
76 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this)); |
|
77 mDisallowBigImage = aDisallowBigImage; |
|
78 Mutated(); |
|
79 } |
|
80 } |
|
81 |
|
82 protected: |
|
83 ImageLayer(LayerManager* aManager, void* aImplData); |
|
84 ~ImageLayer(); |
|
85 virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix); |
|
86 |
|
87 |
|
88 nsRefPtr<ImageContainer> mContainer; |
|
89 GraphicsFilter mFilter; |
|
90 gfx::IntSize mScaleToSize; |
|
91 ScaleMode mScaleMode; |
|
92 bool mDisallowBigImage; |
|
93 }; |
|
94 |
|
95 } |
|
96 } |
|
97 |
|
98 #endif /* GFX_IMAGELAYER_H */ |