Bug 856272; don't round our mask size too early so we get a proper transform for small surfaces. r=roc

This commit is contained in:
Nicholas Cameron 2013-04-05 16:16:38 +13:00
parent 7e1edc36a1
commit b2e31373d7

View File

@ -3739,16 +3739,16 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
uint32_t maxSize = mManager->GetMaxTextureSize();
NS_ASSERTION(maxSize > 0, "Invalid max texture size");
nsIntSize surfaceSize(std::min<int32_t>(boundingRect.Width(), maxSize),
std::min<int32_t>(boundingRect.Height(), maxSize));
gfxSize surfaceSize(std::min<float>(boundingRect.Width(), maxSize),
std::min<float>(boundingRect.Height(), maxSize));
// maskTransform is applied to the clip when it is painted into the mask (as a
// component of imageTransform), and its inverse used when the mask is used for
// masking.
// It is the transform from the masked layer's space to mask space
gfxMatrix maskTransform;
maskTransform.Scale(float(surfaceSize.width)/float(boundingRect.Width()),
float(surfaceSize.height)/float(boundingRect.Height()));
maskTransform.Scale(surfaceSize.width/boundingRect.Width(),
surfaceSize.height/boundingRect.Height());
maskTransform.Translate(-boundingRect.TopLeft());
// imageTransform is only used when the clip is painted to the mask
gfxMatrix imageTransform = maskTransform;
@ -3772,9 +3772,11 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
GetMaskLayerImageCache()->FindImageFor(&lookupKey);
if (!container) {
nsIntSize surfaceSizeInt = nsIntSize(NSToIntCeil(surfaceSize.width),
NSToIntCeil(surfaceSize.height));
// no existing mask image, so build a new one
nsRefPtr<gfxASurface> surface =
aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize);
aLayer->Manager()->CreateOptimalMaskSurface(surfaceSizeInt);
// fail if we can't get the right surface
if (!surface || surface->CairoStatus()) {
@ -3798,7 +3800,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
NS_ASSERTION(image, "Could not create image container for mask layer.");
CairoImage::Data data;
data.mSurface = surface;
data.mSize = surfaceSize;
data.mSize = surfaceSizeInt;
static_cast<CairoImage*>(image.get())->SetData(data);
container->SetCurrentImageInTransaction(image);