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
21 namespace layerscope
{
23 } // namespace layerscope
26 * A Layer which renders an Image.
28 class ImageLayer
: public Layer
{
31 * CONSTRUCTION PHASE ONLY
32 * Set the ImageContainer. aContainer must have the same layer manager
35 virtual void SetContainer(ImageContainer
* aContainer
);
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
;
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
) {
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; }
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
;
88 gfx::Matrix4x4 mEffectiveTransformForBuffer
;
92 } // namespace mozilla
94 #endif /* GFX_IMAGELAYER_H */