2010-05-17 21:04:22 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-01 15:09:35 -08:00
|
|
|
|
|
|
|
#ifndef GFX_IMAGELAYER_H
|
|
|
|
#define GFX_IMAGELAYER_H
|
|
|
|
|
|
|
|
#include "Layers.h"
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
#include "ImageTypes.h"
|
2011-12-15 02:26:42 -08:00
|
|
|
#include "nsISupportsImpl.h"
|
2010-03-01 15:09:35 -08:00
|
|
|
#include "gfxPattern.h"
|
2011-09-27 15:19:24 -07:00
|
|
|
|
2010-03-01 15:09:35 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
class ImageContainer;
|
2010-03-01 15:09:35 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A Layer which renders an Image.
|
|
|
|
*/
|
|
|
|
class THEBES_API ImageLayer : public Layer {
|
|
|
|
public:
|
2012-03-12 18:41:29 -07:00
|
|
|
enum ScaleMode {
|
|
|
|
SCALE_NONE,
|
2012-09-17 20:16:15 -07:00
|
|
|
SCALE_STRETCH
|
2012-03-12 18:41:29 -07:00
|
|
|
// Unimplemented - SCALE_PRESERVE_ASPECT_RATIO_CONTAIN
|
|
|
|
};
|
|
|
|
|
2010-03-01 15:09:35 -08:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the ImageContainer. aContainer must have the same layer manager
|
|
|
|
* as this layer.
|
|
|
|
*/
|
2012-08-19 12:33:25 -07:00
|
|
|
void SetContainer(ImageContainer* aContainer);
|
|
|
|
|
2010-03-01 15:09:35 -08:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the filter used to resample this image if necessary.
|
|
|
|
*/
|
|
|
|
void SetFilter(gfxPattern::GraphicsFilter aFilter) { mFilter = aFilter; }
|
|
|
|
|
2012-03-12 18:41:29 -07:00
|
|
|
/**
|
|
|
|
* CONSTRUCTION PHASE ONLY
|
|
|
|
* Set the size to scale the image to and the mode at which to scale.
|
|
|
|
*/
|
|
|
|
void SetScaleToSize(const gfxIntSize &aSize, ScaleMode aMode)
|
|
|
|
{
|
|
|
|
mScaleToSize = aSize;
|
|
|
|
mScaleMode = aMode;
|
|
|
|
}
|
|
|
|
|
2012-07-03 17:24:55 -07:00
|
|
|
|
2010-03-01 15:09:35 -08:00
|
|
|
ImageContainer* GetContainer() { return mContainer; }
|
|
|
|
gfxPattern::GraphicsFilter GetFilter() { return mFilter; }
|
2012-08-28 22:47:18 -07:00
|
|
|
const gfxIntSize& GetScaleToSize() { return mScaleToSize; }
|
|
|
|
ScaleMode GetScaleMode() { return mScaleMode; }
|
2010-03-01 15:09:35 -08:00
|
|
|
|
2010-07-21 11:06:33 -07:00
|
|
|
MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
|
2010-07-01 18:01:09 -07:00
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface);
|
2010-11-08 01:06:15 -08:00
|
|
|
|
2012-05-22 16:14:03 -07:00
|
|
|
/**
|
|
|
|
* if true, the image will only be backed by a single tile texture
|
|
|
|
*/
|
|
|
|
void SetForceSingleTile(bool aForceSingleTile)
|
|
|
|
{
|
|
|
|
mForceSingleTile = aForceSingleTile;
|
|
|
|
Mutated();
|
|
|
|
}
|
|
|
|
|
2010-03-01 15:09:35 -08:00
|
|
|
protected:
|
2012-08-19 12:33:25 -07:00
|
|
|
ImageLayer(LayerManager* aManager, void* aImplData);
|
|
|
|
~ImageLayer();
|
2010-07-21 11:06:33 -07:00
|
|
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
|
|
|
|
2012-03-12 18:41:29 -07:00
|
|
|
|
2010-03-01 15:09:35 -08:00
|
|
|
nsRefPtr<ImageContainer> mContainer;
|
|
|
|
gfxPattern::GraphicsFilter mFilter;
|
2012-03-12 18:41:29 -07:00
|
|
|
gfxIntSize mScaleToSize;
|
|
|
|
ScaleMode mScaleMode;
|
2012-05-22 16:14:03 -07:00
|
|
|
bool mForceSingleTile;
|
2010-03-01 15:09:35 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GFX_IMAGELAYER_H */
|