2012-01-31 18:18:30 -08: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/. */
|
2012-01-31 18:18:30 -08:00
|
|
|
|
|
|
|
#include "ImageLayers.h"
|
2012-08-19 12:33:25 -07:00
|
|
|
#include "ImageContainer.h"
|
2012-01-31 18:18:30 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData)
|
|
|
|
: Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD)
|
|
|
|
, mScaleMode(SCALE_NONE), mForceSingleTile(false)
|
|
|
|
{}
|
2012-02-15 19:26:19 -08:00
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
ImageLayer::~ImageLayer()
|
|
|
|
{}
|
2012-02-15 19:26:19 -08:00
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
void ImageLayer::SetContainer(ImageContainer* aContainer)
|
2012-01-31 18:18:30 -08:00
|
|
|
{
|
2012-08-19 12:33:25 -07:00
|
|
|
mContainer = aContainer;
|
2012-01-31 18:18:30 -08:00
|
|
|
}
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
void ImageLayer::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
|
2012-01-31 18:18:30 -08:00
|
|
|
{
|
2012-09-17 20:16:15 -07:00
|
|
|
gfx3DMatrix local = GetLocalTransform();
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
// Snap image edges to pixel boundaries
|
2012-09-17 20:16:15 -07:00
|
|
|
gfxRect sourceRect(0, 0, 0, 0);
|
2012-08-19 12:33:25 -07:00
|
|
|
if (mContainer) {
|
2012-09-17 20:16:15 -07:00
|
|
|
sourceRect.SizeTo(mContainer->GetCurrentSize());
|
|
|
|
if (mScaleMode != SCALE_NONE &&
|
|
|
|
sourceRect.width != 0.0 && sourceRect.height != 0.0) {
|
|
|
|
NS_ASSERTION(mScaleMode == SCALE_STRETCH,
|
|
|
|
"No other scalemodes than stretch and none supported yet.");
|
|
|
|
local.Scale(mScaleToSize.width / sourceRect.width,
|
|
|
|
mScaleToSize.height / sourceRect.height, 1.0);
|
|
|
|
}
|
2012-01-31 18:18:30 -08:00
|
|
|
}
|
2012-08-19 12:33:25 -07:00
|
|
|
// Snap our local transform first, and snap the inherited transform as well.
|
|
|
|
// This makes our snapping equivalent to what would happen if our content
|
|
|
|
// was drawn into a ThebesLayer (gfxContext would snap using the local
|
|
|
|
// transform, then we'd snap again when compositing the ThebesLayer).
|
|
|
|
mEffectiveTransform =
|
2012-09-17 20:16:15 -07:00
|
|
|
SnapTransform(local, sourceRect, nullptr) *
|
2012-12-06 15:58:13 -08:00
|
|
|
SnapTransformTranslation(aTransformToSurface, nullptr);
|
2012-08-19 12:33:25 -07:00
|
|
|
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
2012-02-15 19:26:19 -08:00
|
|
|
}
|
2012-01-31 18:18:30 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|