mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
b=777946 implement SCALE_STRETCH through ComputeEffectiveTransforms r=Bas
--HG-- extra : transplant_source : 6%CC%1F3%D1g%A7%098%7E%24%3DC%1D6N%F5%1Ax%0F
This commit is contained in:
parent
a22376f716
commit
aa475bd54a
@ -24,18 +24,26 @@ 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 &&
|
||||
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);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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.
|
||||
|
@ -181,7 +181,7 @@ ImageLayerD3D10::RenderLayer()
|
||||
return;
|
||||
}
|
||||
|
||||
gfxIntSize size = mScaleMode == SCALE_NONE ? image->GetSize() : mScaleToSize;
|
||||
gfxIntSize size = image->GetSize();
|
||||
|
||||
SetEffectTransformAndOpacity();
|
||||
|
||||
|
@ -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)
|
||||
|
@ -247,8 +247,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 =
|
||||
|
Loading…
Reference in New Issue
Block a user