Bug 1520158 - Avoid scene rebuilding for image frame updates if possible. r=jrmuizel

We already avoid scene rebuilding for animated image frame updates, but
we can easily apply this to still images. If the decoding is happening
slowly and in chunks for some reason (really large image, slow network),
then we may save some work.
This commit is contained in:
Andrew Osmond 2019-01-18 22:21:30 -05:00
Родитель c80009663b
Коммит fde57ca333
3 изменённых файлов: 15 добавлений и 5 удалений

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

@ -57,7 +57,7 @@ void WebRenderBackgroundData::AddWebRenderCommands(
RefPtr<WebRenderImageData> image =
GetWebRenderUserData<WebRenderImageData>(aFrame, type);
if (image && image->IsAsyncAnimatedImage()) {
if (image && image->UsingSharedSurface()) {
return true;
}
@ -93,8 +93,18 @@ WebRenderImageData::~WebRenderImageData() {
}
}
bool WebRenderImageData::IsAsyncAnimatedImage() const {
return mContainer && mContainer->GetSharedSurfacesAnimation();
bool WebRenderImageData::UsingSharedSurface() const {
if (!mContainer || !mKey || mOwnsKey) {
return false;
}
// If this is just an update with the same image key, then we know that the
// share request initiated an asynchronous update so that we don't need to
// rebuild the scene.
wr::ImageKey key;
nsresult rv = SharedSurfacesChild::Share(mContainer, mManager,
mManager->AsyncResourceUpdates(), key);
return NS_SUCCEEDED(rv) && mKey.ref() == key;
}
void WebRenderImageData::ClearImageKey() {

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

@ -147,7 +147,7 @@ class WebRenderImageData : public WebRenderUserData {
bool IsAsync() { return mPipelineId.isSome(); }
bool IsAsyncAnimatedImage() const;
bool UsingSharedSurface() const;
protected:
virtual void ClearImageKey();

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

@ -516,7 +516,7 @@ static void InvalidateImages(nsIFrame* aFrame) {
break;
case layers::WebRenderUserData::UserDataType::eImage:
if (static_cast<layers::WebRenderImageData*>(data.get())
->IsAsyncAnimatedImage()) {
->UsingSharedSurface()) {
break;
}
MOZ_FALLTHROUGH;