Bug 1632310 [wpt PR 23186] - Add test for computed versus resolved style., a=testonly
[gecko.git] / gfx / layers / ImageLayers.h
blob90e59fc25b65fcbf1cd17dcf5d1bd039ebc8b905
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/. */
7 #ifndef GFX_IMAGELAYER_H
8 #define GFX_IMAGELAYER_H
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
16 namespace mozilla {
17 namespace layers {
19 class ImageContainer;
21 namespace layerscope {
22 class LayersPacket;
23 } // namespace layerscope
25 /**
26 * A Layer which renders an Image.
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.
35 virtual void SetContainer(ImageContainer* aContainer);
37 /**
38 * CONSTRUCTION PHASE ONLY
39 * Set the filter used to resample this image if necessary.
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();
49 /**
50 * CONSTRUCTION PHASE ONLY
51 * Set the size to scale the image to and the mode at which to scale.
53 void SetScaleToSize(const gfx::IntSize& aSize, ScaleMode aMode) {
54 if (mScaleToSize != aSize || mScaleMode != aMode) {
55 mScaleToSize = aSize;
56 mScaleMode = aMode;
57 Mutated();
61 ImageContainer* GetContainer() { return mContainer; }
62 gfx::SamplingFilter GetSamplingFilter() { return mSamplingFilter; }
63 const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
64 ScaleMode GetScaleMode() { return mScaleMode; }
66 MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
68 void ComputeEffectiveTransforms(
69 const gfx::Matrix4x4& aTransformToSurface) override;
71 const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const override {
72 return mEffectiveTransformForBuffer;
75 ImageLayer* AsImageLayer() override { return this; }
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;
84 RefPtr<ImageContainer> mContainer;
85 gfx::SamplingFilter mSamplingFilter;
86 gfx::IntSize mScaleToSize;
87 ScaleMode mScaleMode;
88 gfx::Matrix4x4 mEffectiveTransformForBuffer;
91 } // namespace layers
92 } // namespace mozilla
94 #endif /* GFX_IMAGELAYER_H */