зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1504699 - Part 4. Add method to SharedSurfacesChild to cast to a shared surface. r=nical
Differential Revision: https://phabricator.services.mozilla.com/D10900
This commit is contained in:
Родитель
dcd4382cfc
Коммит
01269d4189
|
@ -403,7 +403,8 @@ public:
|
|||
bool IsDataSourceSurface() const {
|
||||
SurfaceType type = GetType();
|
||||
return type == SurfaceType::DATA ||
|
||||
type == SurfaceType::DATA_SHARED;
|
||||
type == SurfaceType::DATA_SHARED ||
|
||||
type == SurfaceType::DATA_RECYCLING_SHARED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,8 @@ enum class SurfaceType : int8_t {
|
|||
RECORDING, /* Surface used for recording */
|
||||
TILED, /* Surface from a tiled DrawTarget */
|
||||
DATA_SHARED, /* Data surface using shared memory */
|
||||
CAPTURE /* Data from a DrawTargetCapture */
|
||||
CAPTURE, /* Data from a DrawTargetCapture */
|
||||
DATA_RECYCLING_SHARED /* Data surface using shared memory */
|
||||
};
|
||||
|
||||
enum class SurfaceFormat : int8_t {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "SharedSurfacesParent.h"
|
||||
#include "CompositorManagerChild.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/image/RecyclingSourceSurface.h"
|
||||
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
||||
#include "mozilla/layers/WebRenderBridgeChild.h"
|
||||
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||
|
@ -156,6 +157,24 @@ SharedSurfacesChild::SharedUserData::UpdateKey(WebRenderLayerManager* aManager,
|
|||
return key;
|
||||
}
|
||||
|
||||
/* static */ SourceSurfaceSharedData*
|
||||
SharedSurfacesChild::AsSourceSurfaceSharedData(SourceSurface* aSurface)
|
||||
{
|
||||
MOZ_ASSERT(aSurface);
|
||||
switch (aSurface->GetType()) {
|
||||
case SurfaceType::DATA_SHARED:
|
||||
return static_cast<SourceSurfaceSharedData*>(aSurface);
|
||||
case SurfaceType::DATA_RECYCLING_SHARED: {
|
||||
auto recycleSurface =
|
||||
static_cast<image::RecyclingSourceSurface*>(aSurface);
|
||||
auto childSurface = recycleSurface->GetChildSurface();
|
||||
return static_cast<SourceSurfaceSharedData*>(childSurface);
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
SharedSurfacesChild::DestroySharedUserData(void* aClosure)
|
||||
{
|
||||
|
@ -338,11 +357,11 @@ SharedSurfacesChild::Share(ImageContainer* aContainer,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (surface->GetType() != SurfaceType::DATA_SHARED) {
|
||||
auto sharedSurface = AsSourceSurfaceSharedData(surface);
|
||||
if (!sharedSurface) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(surface.get());
|
||||
SharedSurfacesAnimation* anim = aContainer->GetSharedSurfacesAnimation();
|
||||
if (anim) {
|
||||
return anim->UpdateKey(surface, sharedSurface, aManager, aResources, aKey);
|
||||
|
@ -358,14 +377,14 @@ SharedSurfacesChild::Share(SourceSurface* aSurface,
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aSurface);
|
||||
|
||||
if (aSurface->GetType() != SurfaceType::DATA_SHARED) {
|
||||
auto sharedSurface = AsSourceSurfaceSharedData(aSurface);
|
||||
if (!sharedSurface) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// The external image ID does not change with the invalidation counter. The
|
||||
// caller of this should be aware of the invalidations of the surface through
|
||||
// another mechanism (e.g. imgRequestProxy listener notifications).
|
||||
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(aSurface);
|
||||
SharedUserData* data = nullptr;
|
||||
nsresult rv = ShareInternal(sharedSurface, &data);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -443,7 +462,8 @@ SharedSurfacesChild::UpdateAnimation(ImageContainer* aContainer,
|
|||
MOZ_ASSERT(aSurface);
|
||||
|
||||
// If we aren't using shared surfaces, then is nothing to do.
|
||||
if (aSurface->GetType() != SurfaceType::DATA_SHARED) {
|
||||
auto sharedSurface = SharedSurfacesChild::AsSourceSurfaceSharedData(aSurface);
|
||||
if (!sharedSurface) {
|
||||
MOZ_ASSERT(!aContainer->GetSharedSurfacesAnimation());
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -452,7 +472,6 @@ SharedSurfacesChild::UpdateAnimation(ImageContainer* aContainer,
|
|||
aContainer->EnsureSharedSurfacesAnimation();
|
||||
MOZ_ASSERT(anim);
|
||||
|
||||
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(aSurface);
|
||||
return anim->SetCurrentFrame(aSurface, sharedSurface, aDirtyRect);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,13 @@ public:
|
|||
static Maybe<wr::ExternalImageId>
|
||||
GetExternalId(const gfx::SourceSurfaceSharedData* aSurface);
|
||||
|
||||
/**
|
||||
* Get the surface (or its underlying surface) as a SourceSurfaceSharedData
|
||||
* pointer, if valid.
|
||||
*/
|
||||
static gfx::SourceSurfaceSharedData*
|
||||
AsSourceSurfaceSharedData(gfx::SourceSurface* aSurface);
|
||||
|
||||
static nsresult UpdateAnimation(ImageContainer* aContainer,
|
||||
gfx::SourceSurface* aSurface,
|
||||
const gfx::IntRect& aDirtyRect);
|
||||
|
|
|
@ -935,7 +935,8 @@ imgFrame::FinalizeSurfaceInternal()
|
|||
mMonitor.AssertCurrentThreadOwns();
|
||||
|
||||
// Not all images will have mRawSurface to finalize (i.e. paletted images).
|
||||
if (!mRawSurface || mRawSurface->GetType() != SurfaceType::DATA_SHARED) {
|
||||
if (mShouldRecycle || !mRawSurface ||
|
||||
mRawSurface->GetType() != SurfaceType::DATA_SHARED) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1080,6 +1081,10 @@ RecyclingSourceSurface::RecyclingSourceSurface(imgFrame* aParent, DataSourceSurf
|
|||
{
|
||||
mParent->mMonitor.AssertCurrentThreadOwns();
|
||||
++mParent->mRecycleLockCount;
|
||||
|
||||
if (aSurface->GetType() == SurfaceType::DATA_SHARED) {
|
||||
mType = SurfaceType::DATA_RECYCLING_SHARED;
|
||||
}
|
||||
}
|
||||
|
||||
RecyclingSourceSurface::~RecyclingSourceSurface()
|
||||
|
|
Загрузка…
Ссылка в новой задаче