b=777946 implement SCALE_STRETCH through ComputeEffectiveTransforms r=Bas

--HG--
extra : transplant_source : %9AZ%89%90_4%08R%C5%0E%AB1%40g%23.%7Bo%EE%2A
This commit is contained in:
Karl Tomlinson 2012-09-17 17:19:59 +12:00
parent 3f52f70c45
commit c8293dcec2
6 changed files with 14 additions and 18 deletions

View File

@ -24,18 +24,25 @@ void ImageLayer::SetContainer(ImageContainer* aContainer)
void ImageLayer::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
{
gfx3DMatrix local = GetLocalTransform();
// Snap image edges to pixel boundaries
gfxRect snap(0, 0, 0, 0);
gfxRect sourceRect(0, 0, 0, 0);
if (mContainer) {
gfxIntSize size = mContainer->GetCurrentSize();
snap.SizeTo(gfxSize(size.width, size.height));
sourceRect.SizeTo(mContainer->GetCurrentSize());
if (mScaleMode != SCALE_NONE) {
NS_ASSERTION(mScaleMode == SCALE_STRETCH,
"No other scalemodes than stretch and none supported yet.");
local.Scale(mScaleToSize.width / sourceRect.width,
mScaleToSize.height / sourceRect.height, 0.0);
}
}
// 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 =
SnapTransform(GetLocalTransform(), snap, nullptr)*
SnapTransform(local, sourceRect, nullptr)*
SnapTransform(aTransformToSurface, gfxRect(0, 0, 0, 0), nullptr);
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
}

View File

@ -24,7 +24,7 @@ class THEBES_API ImageLayer : public Layer {
public:
enum ScaleMode {
SCALE_NONE,
SCALE_STRETCH // Unimplemented on GL layers and e10s
SCALE_STRETCH
// Unimplemented - SCALE_PRESERVE_ASPECT_RATIO_CONTAIN
};

View File

@ -98,15 +98,6 @@ BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
}
pat->SetFilter(mFilter);
gfxIntSize sourceSize = surface->GetSize();
if (mScaleMode != SCALE_NONE) {
NS_ASSERTION(mScaleMode == SCALE_STRETCH,
"No other scalemodes than stretch and none supported yet.");
gfxMatrix mat = pat->GetMatrix();
mat.Scale(float(sourceSize.width) / mScaleToSize.width, float(sourceSize.height) / mScaleToSize.height);
pat->SetMatrix(mat);
size = mScaleToSize;
}
// The visible region can extend outside the image, so just draw
// within the image bounds.

View File

@ -181,7 +181,7 @@ ImageLayerD3D10::RenderLayer()
return;
}
gfxIntSize size = mScaleMode == SCALE_NONE ? image->GetSize() : mScaleToSize;
gfxIntSize size = image->GetSize();
SetEffectTransformAndOpacity();

View File

@ -368,7 +368,7 @@ ImageLayerD3D9::RenderLayer()
SetShaderTransformAndOpacity();
gfxIntSize size = mScaleMode == SCALE_NONE ? image->GetSize() : mScaleToSize;
gfxIntSize size = image->GetSize();
if (image->GetFormat() == CAIRO_SURFACE ||
image->GetFormat() == REMOTE_IMAGE_BITMAP)

View File

@ -246,8 +246,6 @@ ImageLayerOGL::RenderLayer(int,
NS_ASSERTION(image->GetFormat() != REMOTE_IMAGE_BITMAP,
"Remote images aren't handled yet in OGL layers!");
NS_ASSERTION(mScaleMode == SCALE_NONE,
"Scale modes other than none not handled yet in OGL layers!");
if (image->GetFormat() == PLANAR_YCBCR) {
PlanarYCbCrImage *yuvImage =