зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1428558
- Part 6. Integrate SharedSurfacesAnimation with ImageContainer. r=nical
This patch embeds a SharedSurfacesAnimation object inside an ImageContainer. This allows any consumers of the container to get the single shared ImageKey for an animation, despite whatever surfaces may be held inside the container at a given time. Differential Revision: https://phabricator.services.mozilla.com/D7503
This commit is contained in:
Родитель
6a77ac0bd5
Коммит
aa6a92d381
|
@ -19,6 +19,7 @@
|
|||
#include "mozilla/layers/ImageClient.h" // for ImageClient
|
||||
#include "mozilla/layers/LayersMessages.h"
|
||||
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
|
||||
#include "mozilla/layers/SharedSurfacesChild.h" // for SharedSurfacesAnimation
|
||||
#include "mozilla/layers/SharedRGBImage.h"
|
||||
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
|
@ -190,6 +191,15 @@ ImageContainer::EnsureImageClient()
|
|||
}
|
||||
}
|
||||
|
||||
SharedSurfacesAnimation*
|
||||
ImageContainer::EnsureSharedSurfacesAnimation()
|
||||
{
|
||||
if (!mSharedAnimation) {
|
||||
mSharedAnimation = new SharedSurfacesAnimation();
|
||||
}
|
||||
return mSharedAnimation;
|
||||
}
|
||||
|
||||
ImageContainer::ImageContainer(Mode flag)
|
||||
: mRecursiveMutex("ImageContainer.mRecursiveMutex"),
|
||||
mGenerationCounter(++sGenerationCounter),
|
||||
|
|
|
@ -162,6 +162,7 @@ class ImageCompositeNotification;
|
|||
class ImageContainer;
|
||||
class ImageContainerChild;
|
||||
class SharedPlanarYCbCrImage;
|
||||
class SharedSurfacesAnimation;
|
||||
class PlanarYCbCrImage;
|
||||
class TextureClient;
|
||||
class KnowsCompositor;
|
||||
|
@ -640,6 +641,13 @@ public:
|
|||
|
||||
void DropImageClient();
|
||||
|
||||
SharedSurfacesAnimation* GetSharedSurfacesAnimation() const
|
||||
{
|
||||
return mSharedAnimation;
|
||||
}
|
||||
|
||||
SharedSurfacesAnimation* EnsureSharedSurfacesAnimation();
|
||||
|
||||
private:
|
||||
typedef mozilla::RecursiveMutex RecursiveMutex;
|
||||
|
||||
|
@ -700,6 +708,8 @@ private:
|
|||
// asynchronusly using the ImageBridge IPDL protocol.
|
||||
RefPtr<ImageClient> mImageClient;
|
||||
|
||||
nsAutoPtr<SharedSurfacesAnimation> mSharedAnimation;
|
||||
|
||||
bool mIsAsync;
|
||||
CompositableHandle mAsyncContainerHandle;
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "SharedSurfacesParent.h"
|
||||
#include "CompositorManagerChild.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/layers/IpcResourceUpdateQueue.h"
|
||||
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
||||
#include "mozilla/layers/WebRenderBridgeChild.h"
|
||||
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||
|
@ -344,6 +343,11 @@ SharedSurfacesChild::Share(ImageContainer* aContainer,
|
|||
}
|
||||
|
||||
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(surface.get());
|
||||
SharedSurfacesAnimation* anim = aContainer->GetSharedSurfacesAnimation();
|
||||
if (anim) {
|
||||
return anim->UpdateKey(sharedSurface, aManager, aResources, aKey);
|
||||
}
|
||||
|
||||
return Share(sharedSurface, aManager, aResources, aKey);
|
||||
}
|
||||
|
||||
|
@ -428,6 +432,30 @@ SharedSurfacesChild::GetExternalId(const SourceSurfaceSharedData* aSurface)
|
|||
return Some(data->Id());
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
SharedSurfacesChild::UpdateAnimation(ImageContainer* aContainer,
|
||||
SourceSurface* aSurface,
|
||||
const IntRect& aDirtyRect)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aContainer);
|
||||
MOZ_ASSERT(!aContainer->IsAsync());
|
||||
MOZ_ASSERT(aSurface);
|
||||
|
||||
// If we aren't using shared surfaces, then is nothing to do.
|
||||
if (aSurface->GetType() != SurfaceType::DATA_SHARED) {
|
||||
MOZ_ASSERT(!aContainer->GetSharedSurfacesAnimation());
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
SharedSurfacesAnimation* anim =
|
||||
aContainer->EnsureSharedSurfacesAnimation();
|
||||
MOZ_ASSERT(anim);
|
||||
|
||||
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(aSurface);
|
||||
return anim->SetCurrentFrame(sharedSurface, aDirtyRect);
|
||||
}
|
||||
|
||||
nsresult
|
||||
SharedSurfacesAnimation::SetCurrentFrame(SourceSurfaceSharedData* aSurface,
|
||||
const gfx::IntRect& aDirtyRect)
|
||||
|
|
|
@ -80,6 +80,10 @@ public:
|
|||
static Maybe<wr::ExternalImageId>
|
||||
GetExternalId(const gfx::SourceSurfaceSharedData* aSurface);
|
||||
|
||||
static nsresult UpdateAnimation(ImageContainer* aContainer,
|
||||
gfx::SourceSurface* aSurface,
|
||||
const gfx::IntRect& aDirtyRect);
|
||||
|
||||
private:
|
||||
SharedSurfacesChild() = delete;
|
||||
~SharedSurfacesChild() = delete;
|
||||
|
|
Загрузка…
Ссылка в новой задаче