2013-08-19 06:59:25 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GFXSHMCOWSURFACEWRAPPER
|
|
|
|
#define GFXSHMCOWSURFACEWRAPPER
|
|
|
|
|
|
|
|
#include "gfxReusableSurfaceWrapper.h"
|
2013-12-03 10:44:38 -08:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-19 06:59:25 -07:00
|
|
|
|
|
|
|
class gfxSharedImageSurface;
|
|
|
|
|
2013-10-07 16:15:59 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
|
|
|
namespace layers {
|
|
|
|
class ISurfaceAllocator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-19 06:59:25 -07:00
|
|
|
/**
|
|
|
|
* A cross-process capable implementation of gfxReusableSurfaceWrapper based
|
|
|
|
* on gfxSharedImageSurface.
|
|
|
|
*/
|
|
|
|
class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper {
|
|
|
|
public:
|
|
|
|
gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator,
|
|
|
|
gfxSharedImageSurface* aSurface);
|
2014-07-15 08:37:45 -07:00
|
|
|
protected:
|
2013-08-19 06:59:25 -07:00
|
|
|
~gfxReusableSharedImageSurfaceWrapper();
|
|
|
|
|
2014-07-15 08:37:45 -07:00
|
|
|
public:
|
2013-08-19 06:59:25 -07:00
|
|
|
const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE;
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat Format() MOZ_OVERRIDE;
|
2013-08-19 06:59:25 -07:00
|
|
|
gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE;
|
|
|
|
void ReadLock() MOZ_OVERRIDE;
|
|
|
|
void ReadUnlock() MOZ_OVERRIDE;
|
|
|
|
|
2013-08-19 06:59:27 -07:00
|
|
|
Type GetType()
|
|
|
|
{
|
|
|
|
return TYPE_SHARED_IMAGE;
|
|
|
|
}
|
|
|
|
|
2013-08-19 06:59:25 -07:00
|
|
|
/**
|
|
|
|
* Returns the shared memory segment that backs the shared image surface.
|
|
|
|
*/
|
|
|
|
mozilla::ipc::Shmem& GetShmem();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a gfxReusableSurfaceWrapper from the shared memory segment of a
|
|
|
|
* gfxSharedImageSurface. A ReadLock must be held, which will be adopted by
|
|
|
|
* the returned gfxReusableSurfaceWrapper.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<gfxReusableSharedImageSurfaceWrapper>
|
|
|
|
Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem);
|
|
|
|
|
|
|
|
private:
|
2013-12-03 10:44:38 -08:00
|
|
|
mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator;
|
2013-08-19 06:59:25 -07:00
|
|
|
nsRefPtr<gfxSharedImageSurface> mSurface;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GFXSHMCOWSURFACEWRAPPER
|