Bug 1143575. Make LayerTreeInvalidation invalidate when an ImageLayerComposite's current frame has changed. r=mattwoodrow

--HG--
extra : commitid : 377gmcdr28S
extra : rebase_source : 2784e6664d1b87442a9045cbdfd82d65e2c8a431
This commit is contained in:
Robert O'Callahan 2015-06-07 12:27:06 +03:00
Родитель 68954a66d8
Коммит 008359665e
2 изменённых файлов: 34 добавлений и 5 удалений

Просмотреть файл

@ -4,6 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "LayerTreeInvalidation.h"
#include <stdint.h> // for uint32_t
#include "ImageContainer.h" // for ImageContainer
#include "ImageLayers.h" // for ImageLayer, etc
@ -23,6 +24,8 @@
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
#include "nsRect.h" // for IntRect
#include "nsTArray.h" // for nsAutoTArray, nsTArray_Impl
#include "mozilla/layers/ImageHost.h"
#include "mozilla/layers/LayerManagerComposite.h"
using namespace mozilla::gfx;
@ -383,16 +386,27 @@ struct ColorLayerProperties : public LayerPropertiesBase
IntRect mBounds;
};
static ImageHost* GetImageHost(ImageLayer* aLayer)
{
LayerComposite* composite = aLayer->AsLayerComposite();
if (composite) {
return static_cast<ImageHost*>(composite->GetCompositableHost());
}
return nullptr;
}
struct ImageLayerProperties : public LayerPropertiesBase
{
explicit ImageLayerProperties(ImageLayer* aImage, bool aIsMask)
: LayerPropertiesBase(aImage)
, mContainer(aImage->GetContainer())
, mImageHost(GetImageHost(aImage))
, mFilter(aImage->GetFilter())
, mScaleToSize(aImage->GetScaleToSize())
, mScaleMode(aImage->GetScaleMode())
, mIsMask(aIsMask)
{
mFrameID = mImageHost ? mImageHost->GetFrameID() : -1;
}
virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
@ -408,30 +422,39 @@ struct ImageLayerProperties : public LayerPropertiesBase
}
ImageContainer* container = imageLayer->GetContainer();
ImageHost* host = GetImageHost(imageLayer);
if (mContainer != container ||
mFilter != imageLayer->GetFilter() ||
mScaleToSize != imageLayer->GetScaleToSize() ||
mScaleMode != imageLayer->GetScaleMode()) {
mScaleMode != imageLayer->GetScaleMode() ||
host != mImageHost ||
(host && host->GetFrameID() != mFrameID)) {
aGeometryChanged = true;
if (mIsMask) {
// Mask layers have an empty visible region, so we have to
// use the image size instead.
IntSize size = container->GetCurrentSize();
IntSize size;
if (container) {
size = container->GetCurrentSize();
}
if (host) {
size = host->GetImageSize();
}
IntRect rect(0, 0, size.width, size.height);
return TransformRect(rect, mLayer->GetLocalTransform());
} else {
return NewTransformedBounds();
}
return NewTransformedBounds();
}
return IntRect();
}
nsRefPtr<ImageContainer> mContainer;
nsRefPtr<ImageHost> mImageHost;
GraphicsFilter mFilter;
gfx::IntSize mScaleToSize;
int32_t mFrameID;
ScaleMode mScaleMode;
bool mIsMask;
};

Просмотреть файл

@ -85,6 +85,12 @@ public:
virtual already_AddRefed<TexturedEffect> GenEffect(const gfx::Filter& aFilter) override;
int32_t GetFrameID()
{
const TimedImage* img = ChooseImage();
return img ? img->mFrameID : -1;
}
protected:
struct TimedImage {
CompositableTextureHostRef mFrontBuffer;