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/. */
6 #ifndef GFX_IMAGELAYER_H
7 #define GFX_IMAGELAYER_H
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
22 namespace layerscope
{
27 * A Layer which renders an Image.
29 class ImageLayer
: public Layer
{
32 * CONSTRUCTION PHASE ONLY
33 * Set the ImageContainer. aContainer must have the same layer manager
36 virtual void SetContainer(ImageContainer
* aContainer
);
39 * CONSTRUCTION PHASE ONLY
40 * Set the filter used to resample this image if necessary.
42 void SetFilter(GraphicsFilter aFilter
)
44 if (mFilter
!= aFilter
) {
45 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
52 * CONSTRUCTION PHASE ONLY
53 * Set the size to scale the image to and the mode at which to scale.
55 void SetScaleToSize(const gfx::IntSize
&aSize
, ScaleMode aMode
)
57 if (mScaleToSize
!= aSize
|| mScaleMode
!= aMode
) {
65 ImageContainer
* GetContainer() { return mContainer
; }
66 GraphicsFilter
GetFilter() { return mFilter
; }
67 const gfx::IntSize
& GetScaleToSize() { return mScaleToSize
; }
68 ScaleMode
GetScaleMode() { return mScaleMode
; }
70 MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE
)
72 virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4
& aTransformToSurface
) MOZ_OVERRIDE
;
74 virtual const gfx::Matrix4x4
& GetEffectiveTransformForBuffer() const MOZ_OVERRIDE
76 return mEffectiveTransformForBuffer
;
80 * if true, the image will only be backed by a single tile texture
82 void SetDisallowBigImage(bool aDisallowBigImage
)
84 if (mDisallowBigImage
!= aDisallowBigImage
) {
85 MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) DisallowBigImage", this));
86 mDisallowBigImage
= aDisallowBigImage
;
92 ImageLayer(LayerManager
* aManager
, void* aImplData
);
94 virtual void PrintInfo(std::stringstream
& aStream
, const char* aPrefix
) MOZ_OVERRIDE
;
95 virtual void DumpPacket(layerscope::LayersPacket
* aPacket
, const void* aParent
) MOZ_OVERRIDE
;
97 nsRefPtr
<ImageContainer
> mContainer
;
98 GraphicsFilter mFilter
;
99 gfx::IntSize mScaleToSize
;
100 ScaleMode mScaleMode
;
101 bool mDisallowBigImage
;
102 gfx::Matrix4x4 mEffectiveTransformForBuffer
;
108 #endif /* GFX_IMAGELAYER_H */