Bug 732988 - Part 1: Add ScaleToSize API to ImageLayers. r=roc

This commit is contained in:
Bas Schouten
2012-03-11 22:33:22 +00:00
parent 8395dac6a9
commit aaea2626d5
5 changed files with 47 additions and 18 deletions

View File

@@ -581,6 +581,12 @@ private:
*/
class THEBES_API ImageLayer : public Layer {
public:
enum ScaleMode {
SCALE_NONE,
SCALE_STRETCH // Unimplemented on GL layers and e10s
// Unimplemented - SCALE_PRESERVE_ASPECT_RATIO_CONTAIN
};
/**
* CONSTRUCTION PHASE ONLY
* Set the ImageContainer. aContainer must have the same layer manager
@@ -596,6 +602,17 @@ public:
*/
void SetFilter(gfxPattern::GraphicsFilter aFilter) { mFilter = aFilter; }
/**
* 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;
}
ImageContainer* GetContainer() { return mContainer; }
gfxPattern::GraphicsFilter GetFilter() { return mFilter; }
@@ -620,12 +637,16 @@ public:
protected:
ImageLayer(LayerManager* aManager, void* aImplData)
: Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD) {}
: Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD)
, mScaleMode(SCALE_NONE) {}
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
nsRefPtr<ImageContainer> mContainer;
gfxPattern::GraphicsFilter mFilter;
gfxIntSize mScaleToSize;
ScaleMode mScaleMode;
};
/****** Image subtypes for the different formats ******/