Skip to content

Commit

Permalink
Bug 1143575. Make LayerTreeInvalidation invalidate when an ImageLayer…
Browse files Browse the repository at this point in the history
…Composite's current frame has changed. r=mattwoodrow

--HG--
extra : commitid : 377gmcdr28S
extra : rebase_source : 2784e6664d1b87442a9045cbdfd82d65e2c8a431
  • Loading branch information
rocallahan committed Jun 7, 2015
1 parent 68954a6 commit 0083596
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
33 changes: 28 additions & 5 deletions gfx/layers/LayerTreeInvalidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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;
};
Expand Down
6 changes: 6 additions & 0 deletions gfx/layers/composite/ImageHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class ImageHost : public CompositableHost

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;
Expand Down

0 comments on commit 0083596

Please sign in to comment.