Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef GFX_IMAGELAYER_H
8
#define GFX_IMAGELAYER_H
9
10
#include "Layers.h" // for Layer, etc
11
#include "mozilla/gfx/BaseSize.h" // for BaseSize
12
#include "mozilla/gfx/Point.h" // for IntSize
13
#include "mozilla/layers/LayersTypes.h"
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
void SetSamplingFilter(gfx::SamplingFilter aSamplingFilter) {
42
if (mSamplingFilter != aSamplingFilter) {
43
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
44
mSamplingFilter = aSamplingFilter;
45
Mutated();
46
}
47
}
48
49
/**
50
* CONSTRUCTION PHASE ONLY
51
* Set the size to scale the image to and the mode at which to scale.
52
*/
53
void SetScaleToSize(const gfx::IntSize& aSize, ScaleMode aMode) {
54
if (mScaleToSize != aSize || mScaleMode != aMode) {
55
mScaleToSize = aSize;
56
mScaleMode = aMode;
57
Mutated();
58
}
59
}
60
61
ImageContainer* GetContainer() { return mContainer; }
62
gfx::SamplingFilter GetSamplingFilter() { return mSamplingFilter; }
63
const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
64
ScaleMode GetScaleMode() { return mScaleMode; }
65
66
MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
67
68
void ComputeEffectiveTransforms(
69
const gfx::Matrix4x4& aTransformToSurface) override;
70
71
const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const override {
72
return mEffectiveTransformForBuffer;
73
}
74
75
ImageLayer* AsImageLayer() override { return this; }
76
77
protected:
78
ImageLayer(LayerManager* aManager, void* aImplData);
79
virtual ~ImageLayer();
80
void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
81
void DumpPacket(layerscope::LayersPacket* aPacket,
82
const void* aParent) override;
83
84
RefPtr<ImageContainer> mContainer;
85
gfx::SamplingFilter mSamplingFilter;
86
gfx::IntSize mScaleToSize;
87
ScaleMode mScaleMode;
88
gfx::Matrix4x4 mEffectiveTransformForBuffer;
89
};
90
91
} // namespace layers
92
} // namespace mozilla
93
94
#endif /* GFX_IMAGELAYER_H */