mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 921910 - Invalidate when we change the frame of an asynchronous ImageContainer that is part of a main-thread layer tree. r=roc
This commit is contained in:
parent
fe6c3e297b
commit
76ab12a6bc
@ -20,8 +20,7 @@ VideoFrameContainer::VideoFrameContainer(dom::HTMLMediaElement* aElement,
|
||||
already_AddRefed<ImageContainer> aContainer)
|
||||
: mElement(aElement),
|
||||
mImageContainer(aContainer), mMutex("nsVideoFrameContainer"),
|
||||
mIntrinsicSizeChanged(false), mImageSizeChanged(false),
|
||||
mNeedInvalidation(true)
|
||||
mIntrinsicSizeChanged(false), mImageSizeChanged(false)
|
||||
{
|
||||
NS_ASSERTION(aElement, "aElement must not be null");
|
||||
NS_ASSERTION(mImageContainer, "aContainer must not be null");
|
||||
@ -61,7 +60,6 @@ void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
|
||||
gfxIntSize newFrameSize = mImageContainer->GetCurrentSize();
|
||||
if (oldFrameSize != newFrameSize) {
|
||||
mImageSizeChanged = true;
|
||||
mNeedInvalidation = true;
|
||||
}
|
||||
|
||||
mPaintTarget = aTargetTime;
|
||||
@ -89,10 +87,6 @@ void VideoFrameContainer::ClearCurrentFrame(bool aResetSize)
|
||||
|
||||
mImageContainer->SetCurrentImage(nullptr);
|
||||
mImageSizeChanged = aResetSize;
|
||||
|
||||
// We removed the current image so we will have to invalidate once
|
||||
// again to setup the ImageContainer <-> Compositor pair.
|
||||
mNeedInvalidation = true;
|
||||
}
|
||||
|
||||
ImageContainer* VideoFrameContainer::GetImageContainer() {
|
||||
@ -110,17 +104,6 @@ void VideoFrameContainer::InvalidateWithFlags(uint32_t aFlags)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Must call on main thread");
|
||||
|
||||
if (!mNeedInvalidation && !(aFlags & INVALIDATE_FORCE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mImageContainer &&
|
||||
mImageContainer->IsAsync() &&
|
||||
mImageContainer->HasCurrentImage() &&
|
||||
!mIntrinsicSizeChanged) {
|
||||
mNeedInvalidation = false;
|
||||
}
|
||||
|
||||
if (!mElement) {
|
||||
// Element has been destroyed
|
||||
return;
|
||||
@ -150,11 +133,16 @@ void VideoFrameContainer::InvalidateWithFlags(uint32_t aFlags)
|
||||
}
|
||||
}
|
||||
|
||||
bool asyncInvalidate = mImageContainer &&
|
||||
mImageContainer->IsAsync() &&
|
||||
!(aFlags & INVALIDATE_FORCE);
|
||||
|
||||
if (frame) {
|
||||
if (invalidateFrame) {
|
||||
frame->InvalidateFrame();
|
||||
} else {
|
||||
frame->InvalidateLayer(nsDisplayItem::TYPE_VIDEO);
|
||||
frame->InvalidateLayer(nsDisplayItem::TYPE_VIDEO, nullptr,
|
||||
asyncInvalidate ? nsIFrame::UPDATE_IS_ASYNC : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,6 @@ protected:
|
||||
// frame is fully invalidated instead of just invalidating for the image change
|
||||
// in the ImageLayer.
|
||||
bool mImageSizeChanged;
|
||||
|
||||
bool mNeedInvalidation;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4995,11 +4995,21 @@ nsIFrame::SchedulePaint(uint32_t aFlags)
|
||||
}
|
||||
|
||||
Layer*
|
||||
nsIFrame::InvalidateLayer(uint32_t aDisplayItemKey, const nsIntRect* aDamageRect)
|
||||
nsIFrame::InvalidateLayer(uint32_t aDisplayItemKey,
|
||||
const nsIntRect* aDamageRect,
|
||||
uint32_t aFlags /* = 0 */)
|
||||
{
|
||||
NS_ASSERTION(aDisplayItemKey > 0, "Need a key");
|
||||
|
||||
Layer* layer = FrameLayerBuilder::GetDedicatedLayer(this, aDisplayItemKey);
|
||||
|
||||
// If the layer is being updated asynchronously, and it's being forwarded
|
||||
// to a compositor, then we don't need to invalidate.
|
||||
if ((aFlags & UPDATE_IS_ASYNC) && layer &&
|
||||
layer->Manager()->GetBackendType() == LAYERS_CLIENT) {
|
||||
return layer;
|
||||
}
|
||||
|
||||
if (aDamageRect && aDamageRect->IsEmpty()) {
|
||||
return layer;
|
||||
}
|
||||
|
@ -2316,9 +2316,15 @@ public:
|
||||
*
|
||||
* @param aDamageRect Area of the layer to invalidate.
|
||||
* @param aDisplayItemKey Display item type.
|
||||
* @param aFlags UPDATE_IS_ASYNC : Will skip the invalidation
|
||||
* if the found layer is being composited by a remote
|
||||
* compositor.
|
||||
* @return Layer, if found, nullptr otherwise.
|
||||
*/
|
||||
Layer* InvalidateLayer(uint32_t aDisplayItemKey, const nsIntRect* aDamageRect = nullptr);
|
||||
enum {
|
||||
UPDATE_IS_ASYNC = 1 << 0
|
||||
};
|
||||
Layer* InvalidateLayer(uint32_t aDisplayItemKey, const nsIntRect* aDamageRect = nullptr, uint32_t aFlags = 0);
|
||||
|
||||
/**
|
||||
* Returns a rect that encompasses everything that might be painted by
|
||||
|
Loading…
Reference in New Issue
Block a user